Results 1 to 2 of 2

Thread: Adding Menu Items

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Location
    Chicago
    Posts
    11

    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..

  2. #2
    Member Vahid's Avatar
    Join Date
    Aug 2002
    Location
    Iran
    Posts
    37

    Wink

    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
  •  



Click Here to Expand Forum to Full Width