I am working working on a GDBG that has Hierarchical View (Tree view) and it is bound to 2 different views. I switch between views on the basis of an event.
now when I sort GDBG using SortBehaviour = SingleClick. The whole grid collapses first and then start to sort. Is there anyway to sort a Grid without affecting its current state??
There is no property setting that allows this to happen.
In the case of sorting, the datasource fires an IBindingList.ListChanged event with a ListChanged.Reset setting. This causes the nodes to reset. To handle this, you can save teh state before sorting, and reset it after sorting. One problem is that the reset also cancels any grid.BeginUpdate which then shows the nodes changing which is not good. One way to handle this is use a Win32 API directly freeze the painting instead of using grid.BeginUpdate.
Here is a sample that works around this problem.
It adds a new property to a derived grid that adds a second way to freeze the screen painting through a Win32 API call. This techique is discussed in one of our Windows Forms FAQ,