Is there a way to suppress the treeview_AfterSelect() event so it isn’t called during form.show().
I have an application that is an MDI Container. One of the child windows contains a treevew. What the user selects on the treeview determines which child windows are shown. Due to a custom control I’m using the treeview form is also one of the windows that is closed and recreated. I’ve managed to mute the event handler and select the required node and then reenable the event handler in the constructor, but when the form is later shown the AfterSelect event is fired. Which is unwanted behavior in my situation.
Thanks in advance
The easiest approach is to use a member variable (e.g. “bool initialised”). It’ll default to false.
At the end of your form’s Shown event handler, set it to true.
In your AfterSelect, ignore the event if (!initialised)