I have an ultragrid in a winform application. The columns are resizable and movable. The data refreshes on a frequent basis (i.e. I go get more data in a dataset and bind it to the ultragrid)
This is probably a dumb question, but...
If the user moves and resizes a few columns, how do I ensure that when the data refreshes the columns retain their size and position instead of going back the way they were initially?
Note, that I don't need this to persist outside of the current session. When the application restarts, the user's modification to the columns can be lost.
Thanks so much,
Steve
Hi Steve,
This question comes up quite a lot, so you might want to search the forums for te word Refresh.
It really comes down to what you mean by "refresh". If your data source is sending Reset notifications, then the grid has to throw away the whole layout and start over, building a new layout from the new data structure which may or may not match the old one. So the best thing to do is try to avoid Reset notificiations from your data source.
If that's not possible, then the only thing you can do is save the grid.DisplayLayout before the reset and then re-load it afterward.
Thanks for replying Mike. By refresh, I mean that I'm building a new dataset (same tables and columns) and rebinding it to the grid. I'll search fro "refresh" in the forums. You mention saving the DisplayLayout. Is this as simple as saving the entire layout or do I have to go through each column and save the atrributes individually - please, oh please let it be the former :)
sweeks said:Is this as simple as saving the entire layout or do I have to go through each column and save the atrributes individually - please, oh please let it be the former :)
It is the former. There are methods on the DisplayLayout for Save and Load. It saves everything the user can customize like column size, position, filtering, sorting, etc.
Thanks Mike! I was able to use these methods to accomplish exactly what I wanted.