I am using the 2006 version of the UltraGrid. Maybe this has changed in the current version, but when I change the hidden value of a column programmatically, the AfterColPosChanged event does not fire. It does fire if I hide/show a column using the column chooser though.
In code I am setting "column.Hidden = true" for a column that is visible in the grid. I would expect to see the AfterColPosChanged event fire and the "e.PosChanged" value equal to "PosChanged.HiddenStateChanged"
Do you know why this event does not fire when a change is made programmatically to the hidden property of a column?
Thanks!
Steve
This is something of a gray area. Some events fire only in response to user action and some fire for both user action and changes made in code. The basic purpose of an event is to let you know that the user changed something. If you changed something in code, you don't need an event to tell you that you did it, because you already know.
Of course, it's often convenient to have all the code that responds to a change in the same place.
What I would do is just take the code you have in AfterColPosChanged out of the event and put it into a method. Then call that method from the event handler and from any other place in your code where you are changing the hidden state of a column.
Thanks Mike! I was hoping to avoid this, but it looks like I will have to make a method like you are saying. In my particular case I have built a user control with an UltraGrid. I have exposed enough of the UltraGrid properties for a user to hide rows or columns or whatever they need to do. So, this is why I was hoping that hiding a column through code would fire the event. The end user of my control is hiding it, not the internal code of my control. I will just have to make a public method and instruct developers to call it after hiding/showing any column programmatically.
Thanks,