Is there some sort of event that gets fired when a user changes the layout of the grid? For example, if a column is moved, grouped, etc.? I'm basically looking for an event that gets fired if anything changes so I can save the new layout. Thanks.
Hi,
There's no single event. What I typically do is just always save the layout when the form closes. Saving a layout is not particularly performance intensive, so it's usually okay to just save it all the time and overwrite any existing layout.
If you want to trap for changes so you can prompt the user, then there are a couple of ways you could do it. One is to trap all of the events that fire when the user changes something in the layout. There are a lot of events for this, though, such as AfterColPosChanged, AfterRowFilterChange, AfterSortChange, etc. It would be tricky just to make sure you got them all.
Another potential option would be to load the existing layout from the hard drive into a memory stream. Or save the grid's initial layout into a memory stream. That gives your original layout.
Then, when you want to see if anything has change, you save the current grid layout into another MemoryStream. Then you loop through the bytes in the streams and compare each byte. I'm not sure how fast or efficient this would be, but it might be worth trying.
Is there a way to save just the column order using the save/loadlayout methods? Thanks.
I looked at the numerous events that could be fired and decided that catching them all wouldn't be the best route to go, so that's why I was hoping there was a single event somewhere that I missed. I think I'm just going to add the equivalent of a 'save it now' button. Thanks for your help.