|
-
Mar 29th, 2000, 11:07 AM
#1
Thread Starter
Lively Member
Does anyone know how to create menus with submenus at runtime.??
-
Mar 29th, 2000, 08:33 PM
#2
New Member
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
-
Mar 29th, 2000, 11:15 PM
#3
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|