|
-
Aug 22nd, 2002, 01:34 PM
#1
Thread Starter
New Member
Adding Menu Items
I started on VB6 about 3 months ago and decided to transition to VB.Net instead. So... I am still trying to grasp basic concepts, so please be gentle.
Is it possible to prompt a user (with a form) and have their input added as a menu item?
Example: I want the user to input a hostname and then have it appear in the main forms menuitem.
Thanks..
-
Aug 28th, 2002, 05:03 PM
#2
Member
Adding user input as a menu item is very easy, Consider you have an existing menu item (myParentMenuItem) that you want to add user input as a sub menu to it, calling 'AddAMenuItem' will add a sub menu with your specified text, See:
Private Sub MyMenuItemsHandler(ByVal sender As System.Object, ByVal e As System.EventArgs)
If (sender Is Nothing) = False Then
With CType(sender, System.Windows.Forms.MenuItem)
System.Windows.Forms.MessageBox.Show(.Text)
End With
End If
End Sub
Private Sub AddAMenuItem(ByVal itemText as String)
Dim tmpMenuItem As New System.Windows.Forms.MenuItem()
tmpMenuItem.Text = itemText
AddHandler tmpMenuItem.Click, AddressOf myMenuItemsHandler
Me.myParentMenuItem.MenuItems.Add(tmpMenuItem)
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|