closing an open form
-
i have a treeview control with about 20 subnodes. each time i click on a new node, a related form opens in the parent window. how can i close the currently opened form once a new node is selected in the treeview control? thanks for your help. :)
First you will need to grab a reference to the parent window and the active window. Then you can close the active window. What I did was set a reference to the parent window in a var. Then I was able to call the variable and get the ActiveMdiChild property and set that property to close. So I have something like this if (parent.ActiveMdiChild != null) { parent.ActiveMdiChild.Close(); }
-
First you will need to grab a reference to the parent window and the active window. Then you can close the active window. What I did was set a reference to the parent window in a var. Then I was able to call the variable and get the ActiveMdiChild property and set that property to close. So I have something like this if (parent.ActiveMdiChild != null) { parent.ActiveMdiChild.Close(); }