Simulate Menu Click

In VB.net, I cannot figure out how to programmatically call a sub-menu, except in the same procedure that I first create the menu.

Private Sub InitializeMenu
...
        Dim menuView As New ToolStripMenuItem
        menuView.Text = "View" 'Assign a text value to the MenuStripItem
        mnuMain.Items.Clear()
        mnuMain.Items.Add(menuView) 'add the MenuStripItem to the main menu

...
           'add a submenu for this grid
            Dim subMenu As New ToolStripMenuItem
            subMenu.Text = GRID_NAME(iGrid)
            menuView.DropDownItems.Add(subMenu)

...
                 menuView.DropDownItems(iGrid).PerformClick()

but I cannot make the performClick work if I am outside of this procedure.

it doesn't seem to make sense to dimension a new one in a new procedure.

This is probably obvious but I'm known for overlooking the obvious.  Thanks for your help!
LovinSpoonfulAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LovinSpoonfulAuthor Commented:
Also, there is another submenu below each menu above.
How do I get retrieve the name of each, and then performClick on the one I want?
0
CodeCruiserCommented:
You would need to declare the submenu in a location which is accessible in both above code and the code where you want to performclick. Probably at class level.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LovinSpoonfulAuthor Commented:
Thanks.  This works.  I also made a generic list of submenu items at the class level so that I could access the 3rd level of menu indentation (subsubMenu) from anywhere within the class.


0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.