Hi guys,
I have .NET CF app, with a form that contains a datagrid which I've bound to a BindingList using a solution derived mainly from this article: http://msdn.microsoft.com/en-us/library/aa480736.aspx
I've hooked it up so that when a column header is clicked, I get the HitTest information and check for the Type. If the Type is ColumnHeader, then I initiate a Sort on the underlying BindingList (Using code similar to the example in the link posted above) - which in turn, makes the DataGrid sort itself according to the Property of T that I have clicked. E.g. Description
This works absolutely fine!
The problem comes when I now click around my datagrid - Let's say I have two rows, after the sort is performed, no row is selected. I click a cell in row 1 and I have code that selects the whole row - this operations occurs and all is well. When I now click row 2, row 2 gets selected and all is well, grid still has my sort applied. If I now click row 1 again, my sorting gets reversed, but crucially, the "ApplySort" method is not actually being called. So what is happening? It only happens when I click row 1, the two rows in the grid effectively are reversed. On selecting row 2, it does not occur.
Upon debugging, I can see that mousedown fires (which i have put a return; statement in) and then MouseUp fires, which does the HitTest and calls ApplySort if the columnheader has been clicked, which in this case it has not. I noticed that the change in sort occurs * AFTER * control has left the MouseUp event - so something, somewhere, seems to be altering my grid state after MouseDown/MouseUp have finished.
Any ideas what event/action could be messing with my Grid? I basically want to know if I can suppress anything and everything else once I have called my ApplySort.