Beginner's Question:

S

Sender

I have created a contextmenu and attached with a button on Form1. There are
four items in the menu. menuitem1, menuitem2, menuitem3, menuitem4. If I on
the same form i.e. Form1 then I can hide menuitem by simply writing
menuitem1.visible = false. However, I want to hide them by writing some code
in form2 which I am calling from form1 using:

dim frm as form2
frm2.show

On form2 I have inserted a button wherein I wanted to write code to hide one
of the menuitems of the contextmenu on form1. How would I do that?

Thanks in advance!
 
H

Herfried K. Wagner [MVP]

Sender said:
I have created a contextmenu and attached with a button on Form1. There are
four items in the menu. menuitem1, menuitem2, menuitem3, menuitem4. If I on
the same form i.e. Form1 then I can hide menuitem by simply writing
menuitem1.visible = false. However, I want to hide them by writing some code
in form2 which I am calling from form1 using:

dim frm as form2
frm2.show

On form2 I have inserted a button wherein I wanted to write code to hide one
of the menuitems of the contextmenu on form1. How would I do that?

You will have to pass a reference to the form to the 2nd form, for
example in a property. You can set this property before showing the
form.

Quick and Dirty:

In Form2:

\\\
..
..
..
Private m_MyForm1 As Form1
..
..
..
Public Property MyForm1() As Form1
Get
Return m_MyForm1
End Get
Set(ByVal Value As Form1)
m_MyForm1 = Value
End Set
End Property
..
..
..
///

Usage:

\\\
Dim f As New Form2()
f.MyForm1 = Me
f.Show()
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top