How to set a MenuStrip Item's Visible property to False from anothe form

mutlyp

Member
Joined
Oct 11, 2012
Messages
8
Programming Experience
10+
I have a MDI form with a MenuStrip on it.
I have another child form for the MDI Form.
What I would like to do is that when the Child Form closes it hides one of the items on the MenuStrip on the MDI Form.
I made the MenuStrip on the MDI Form Public.
then in the Child Form on the Disposed Event I put
mdiForm.MenuStrip1.Items("Open").Visible = False (Open is the name of the item on the MenuStrip I want to hide)
but I get an error "Reference to a non-shared member requires an object reference "
Please help
Thank you
 
Hi,

You need to remember that each ToolStripMenuItem is an object in its own right so you do not need to make a reference to the MenuStrip first to affect the visibility of that item. You will therefore have an object in your form called Open with which you can interact with. That said, the name Open can easily conflict with something else in your project so I would suggest that you call it something else like, tsMIOpen and then just call:-

VB.NET:
Form1.tsMIOpen.Visible = False

Hope that helps.

Cheers,

Ian
 
Back
Top