Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27348

VS 2010 Click event for dynamically created sub menu strip items

$
0
0
Hi

I am relitively new to VB and have a quesdtion regarding the MenuStrip. I have a menu strip on which I have created multiple items/menus via the conventional click in the menu and type the items in there. Then I have one menu item "Coms" under which I have "Baud Rate" and "Com Port" the Com Port sub menu gets its items from the following code.
Code:

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        myPorts = IO.Ports.SerialPort.GetPortNames()
    End Sub

Private Sub ComPortToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ComPortToolStripMenuItem.Click
        ComPortToolStripMenuItem.DropDownItems.AddRange(MyPorts)
    End Sub

Now I have a question. How do I create click events for those items created. Eg if com port 4 is available and displayed in the list if I click on that menu item "Com Port 4" I would like the program to add the selected com port to a textbox (ComsTextBox). I have found some other forum answers to this question however I find that they are not explained well enough for me to understand.

The available com ports will vary also.

Any help would be appreciated.

Viewing all articles
Browse latest Browse all 27348

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>