Winforms Datagrid - detecting SORT

  • Thread starter Thread starter Lee Gillie
  • Start date Start date
L

Lee Gillie

I'm trying to find an event that will help me keep a status area updated
for the grid row under the cursor.

For the most part when a user clicks somewhere in the readonly grid I am
responding to the cell change event, and selecting the entire row. A
custom paint reverses colors. This works great. Even after sorting, I
see how to use the currency manager to find the right dataset record to
show status for the right record in a separate area.

But when someone uses the built in sort feature, I don't get a change
position type event. I've fiddled with mouse-down, and mouse-up, and the
sort has not occurred yet. I am always showing stats for the PREVIOUS
highlighted record when I click a column heading for auto-sort. My
status window is always behind by one. But if the user picks a cell
after the sort, then everything is back in synch.

So I am looking for an event that I can respond to AFTER the sort has
actually happened, that I can update my status area for the new "current
row". It doesn't seem to be coming easily.

Any hints would be greatly appreciated.

Best regards - Lee Gillie, Spokane WA
 
You should be able to hook into the ListChanged event on the list that the
grid is bound to. I believe the event args will have a ListChangeType of
"Reset" after a sort has occurred.

If you're bound to a DataTable then you need to hook into this event on the
DataView.

Hope this helps.

Regards,
Matt Garven
 
Back
Top