I need to be able to restore the width of a column after the width has been changed by the user. How can I retrieve the old width value, that was active, before the change occurred?
I tried the WidthChanged event, but this seems to be too late. The old width is no longer available, when this event raises.
In a future release, it would be nice, if there were Before and After version of each event.
Another question regarding this: how can I get the column, whose width was changed? WidthChanged event handlers only get a default EventArgs object, which does not make much sense. And CurrentColumn does not always return the column, whose width was changed.
In a future release, it would be nice, if all grid/column event handlers would get an EventArgs derivative, that provides enough information about the event.
Imported from legacy forums. Posted by mario.muja (had 2159 views)
You can use the ResetWidth method to restore the width of the column to its original size. And you can define this value by using the DefaultWidth property.
If what you want is the last width, and not the original, then you will need to keep in memory the new value in the WidthChanged event every time it changes, and revert back to this value when you want, but don’t forget to unsubscribe to the event when you do the reverting, and subscribe to it again after.
To get the column in the event handler, use the sender. Simply cast it to a DataBoundColumn or a Column, i.e. :
( ( Column )sender).Width
Imported from legacy forums. Posted by André (had 2930 views)