How to Stop Auto Sorting during Data Binding of a DataGridView with one Column's SortMode set to Pro

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have a Data Bound DataGridView with several columns. I want to programmatically sort the rows based on the values in one of the columns, but not automatically sort every time data binding occurs. I set the sort columns SortMode to Programmatic and the rest of the columns to NotSortable. I then programmatically invoke the DGVs Sort method to sort on the Programmatic column immediately after the initial data binding (i.e. after setting the DGVs DataSource to a DataTable) . So far so good. However, when the user clicks off the DGV, the DGV automatically re-sorts during (or as a result of) a Data Binding triggered at the time of the Leave event. Curiously (to me), the automatic sort does not occur when I remove the programmatic invoke of Sort, implying that invoking Sort once implicitly sets some DGV property that subsequently triggers automatic sorting on the same column. Why is this happening and is there any way to stop it? I only want the sorting done when I programmatically invoke the DGVs Sort method.
Thx. Steve

View the full article
 
Back
Top