Link to home
Start Free TrialLog in
Avatar of iyufa
iyufa

asked on

VS 2005 Build a Menu from VB code

I need an example for VB.net in VS2005. On how to create a menu on a fly.

Menu                              Structure
    OP1                                      GMM
    OP2                                                Inq
                                                          main
                                                 DMM
                                                           Inq
                                                          main
I was requested to do it on the fly not at the design mode.
Thank you. I am a beginner    
ASKER CERTIFIED SOLUTION
Avatar of Joel Coehoorn
Joel Coehoorn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sorry for the delay but I have lots of work today

        Dim mnu As New MenuStrip
        Dim tsmnu As New ToolStripMenuItem("MainMenu")
        tsmnu.DropDownItems.Add("Level1", Nothing, New EventHandler(AddressOf action))
        tsmnu.DropDownItems.Add("Level2", Nothing, New EventHandler(AddressOf action))
        mnu.Items.Add(tsmnu)
        Me.MainMenuStrip = mnu
        Me.Controls.Add(mnu)

       Sub action(ByVal sender As Object, ByVal e As System.EventArgs)
          Dim tsmnu As ToolStripMenuItem = CType(sender, ToolStripMenuItem)
          MsgBox(tsmnu.Text)
      End Sub


Avatar of iyufa
iyufa

ASKER

Where can i get a menustrip?
I could only see the menu control in my VS2005 tools
Avatar of iyufa

ASKER

Once again I am jsut a begginer: I am not sure ai undesetnt the menustrip

Will something like this work:

  Dim itmHome As New MenuItem
        Dim itmMerchandise As New MenuItem
        Dim itmMerchantMgmt As New MenuItem

        itmHome.Text = "Home"
        itmMerchandise.Text = "Merchandise"
        itmMerchantMgmt.Text = "Merchant Mgmt"

        CSMenu.Items.Add(itmHome)
        CSMenu.Items.Add(itmMerchandise)
Avatar of iyufa

ASKER

This is worked. How can i add the children under each of the main header?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Forced accept.

Computer101
EE Admin