At work we had an interesting case of using a DataGridView which needed to be sorted on one column, and then sub-sorted on another. I was a bit worried about how ugly it could be, as I had done a little reading about doing multiple column sorts. Turns out it was a piece of cake and took just a few minutes to get it working. Check out the second sample on this MSDN page (entitled “Custom Sorting Using the SortCompare Event”). Not so bad, eh? I can’t express how much I love DataGridViews.
Oh, and in case anyone is wondering how to set the focus on a particular row of a DataGridView, do something like the following:
dataGridView.Rows[rowid].Selected = true;
//Unselect any other rows here, if necessary
dataGridView.CurrentCell = dataGridView.Rows[rowid].Cells[0″];