Adapting menu if child is opened

  • Thread starter Thread starter Kenny
  • Start date Start date
K

Kenny

I have a main form (an mdi container) with a menu and the item "open".
When clicking "open" a child form appears. Now, i don't want that
several childforms are opened. So i want the "open" item to be
disabled when this child form is shown. When i close this child form
i want the "open" item in the menu to be enabled again so that i can
open the child form whenever i want. How can i do this? Anyone an
idea?

thx.
 
Kenny said:
I have a main form (an mdi container) with a menu and the item
"open".
When clicking "open" a child form appears. Now, i don't want
that
several childforms are opened. So i want the "open" item to be
disabled when this child form is shown. When i close this child
form i want the "open" item in the menu to be enabled again so that i
can open the child form whenever i want. How can i do this? Anyone
an idea?

In the menuitem's click event, set it's enabled property to false (that's
what you probably aready know). After creating the instance of the child
within the MDI container, use the Addhandler statement to handle the closed
event of the child. In the event handler, enable the menuitem.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
Armin Zingler said:
In the menuitem's click event, set it's enabled property to false (that's
what you probably aready know). After creating the instance of the child
within the MDI container, use the Addhandler statement to handle the closed
event of the child. In the event handler, enable the menuitem.

Can you give me some more information cause i don't quite understand.
This handling stuff isn't really my bag.
 
Kenny said:
Can you give me some more information cause i don't quite understand.
This handling stuff isn't really my bag.


In the menuitem's click event, set it's enabled property to false (that's
what you probably aready know).

directcast(sender, menuitem).enabled = false
After creating the instance of the child

private m_Child as form2 'at class level (= field of the class)
'...
m_child = new form2
within the MDI container, use the Addhandler statement to handle the closed
event of the child.

addhandler m_child.closed, addressof ChildClosed
In the event handler, enable the menuitem.

....and remove the handler:

private sub ChildClosed( _
ByVal sender As Object, ByVal e As System.EventArgs)

menuitemx.enabled = true
removehandler m_child.closed, addressof ChildClosed
m_child = nothing
end sub
 
Armin Zingler said:
directcast(sender, menuitem).enabled = false


private m_Child as form2 'at class level (= field of the class)
'...
m_child = new form2


addhandler m_child.closed, addressof ChildClosed


...and remove the handler:

private sub ChildClosed( _
ByVal sender As Object, ByVal e As System.EventArgs)

menuitemx.enabled = true
removehandler m_child.closed, addressof ChildClosed
m_child = nothing
end sub

You are my hero!
 
Back
Top