I have been searching around for how to sort by a set column DESC in the code but everything seems to reference the datagrid sorting a database or something along those lines. If I manually built my datagrid record (Rows.Add), how can I sort the records by the first column so I can keep adding rows?

Use,

dataGridView1.Sort(dataGridView1.Columns["Name"], ListSortDirection.Descending);

if you are using the DataGridView control then adatapost's code will work for you. However, you refered to a DataGrid; does this mean you are using the older DataGrid control or (like so many) did you drop the 'View'? :p

If you are using a DataGrid then there is no .Sort method. How are you adding the rows to the DataGrid? I have aa DataGrid in which i built the data in code by adding rows to a DataTable then assigning the datatable as the DataGrid's DataSource and my columns sort when i click the column headers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.