Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
635
Layout changed event?
posted

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.

Parents
  • 469350
    Verified Answer
    Offline posted

    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.

Reply Children