Results 1 to 3 of 3

Thread: Menu

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 1999
    Location
    Guayaquil, Guayas, Ecuador
    Posts
    87
    Does anyone know how to create menus with submenus at runtime.??

  2. #2
    New Member
    Join Date
    Mar 2000
    Posts
    3
    This solution requires that you build one menu using the menu editor in VB.

    1. Using the menu editor, create a menu. Give it a caption, name, and index. This menu serves as the beginning of a control array. If you don't want to see it in your application, don't check the Visible checkbox.

    2. In your code, when you want to create a new menu, use the following:

    Load <menu name>(index)

    For example, using the menu editor create a menu named mnuMenu.

    Put a command button on your form.

    Put this code in the appropriate place.

    Private Sub Command1_Click()
    Static MaxIdx ' Largest index in array.
    If MaxIdx = 0 Then MaxIdx = 1 ' Preset MaxIdx.
    MaxIdx = MaxIdx + 1 ' Increment index.

    Load mnuMenu(MaxIdx) ' Create new item in array.
    mnuMenu(MaxIdx).Caption = "Menu" + Str(MaxIdx)
    mnuMenu(MaxIdx).Visible = True
    End Sub


    You should see new menus appear across the top of the form.
    You only need the .Visible line if your original menu was not visible.

    To create cascading menus and the contents of these menus at run time, see Creating and Modifying Menus at Run Time in the VB Books On-line or MSDN

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 1999
    Location
    Guayaquil, Guayas, Ecuador
    Posts
    87
    I know how to create menus from an array
    I need to create sub menus indented menus
    Thanks anyway

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