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.
That's what I was afraid of. Thanks Mike.
There are several options you can pass into the Save/Load methods, but they are broad categories. So no, there's no way to save just the column order and nothing else.