hpet
asked on
Menu at run-time
Hi,
I use VB6.
How can i add new topics to menu at runtime?
How free am i modifing menu at runtime?
-Peter
I use VB6.
How can i add new topics to menu at runtime?
How free am i modifing menu at runtime?
-Peter
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Create a control array e.g. mnuFileItem(0), mnuFileItem(1) and so on at design time. Then set the visible property to False for the blank menu controls, and set the visible property to True once you've added text in a control.
Here is an example of some menu items being added at run time. This is based off of a table with some names that are inserted into the menu. Hope this helps.
rstNames is the recordset that contains the names.
mnuFileOpenName(Name_Idx) is the menu item array. During design time, set the index property to zero.
Do Until rstNames.EOF
If Name_Idx > 0 Then
Load Me.mnuFileOpenName(Name_Id x)
'Here we are loading the next instance of the menu item, we only load if it is greater than zero because the menu item with index zero was created at design time.
End If
Me.mnuFileOpenName(Name_Id x).Caption = rstNames!Name 'set the caption for the new menu item
Me.mnuFileOpenName(Name_Id x).visible = true 'showing the new menu item
Name_Idx = Name_Idx + 1 'increment the load index
rstNames.MoveNext 'move to the next record
Loop
rstNames is the recordset that contains the names.
mnuFileOpenName(Name_Idx) is the menu item array. During design time, set the index property to zero.
Do Until rstNames.EOF
If Name_Idx > 0 Then
Load Me.mnuFileOpenName(Name_Id
'Here we are loading the next instance of the menu item, we only load if it is greater than zero because the menu item with index zero was created at design time.
End If
Me.mnuFileOpenName(Name_Id
Me.mnuFileOpenName(Name_Id
Name_Idx = Name_Idx + 1 'increment the load index
rstNames.MoveNext 'move to the next record
Loop
ASKER
Sorry for delay...