Reputation: 694
I'm working in a VB6 project and there is an existing menu, created with the menu creator. I am having trouble to insert subMenu programmatically in a MenuItem.
The first menu is File. It contains two menu items : Choice and Exit.
I would like to insert each row of a query (only the first column) at run time in Choice.
My recordset works well, but i need some help in the code below :
Do While rs_choice.EOF = False
'add column1 in Choice
'~Something~ = rs_choice.Fields("column1").Value
rs_choice.MoveNext
Loop
PS : No one MenuItems have defined index.
Can someone help me ?
Upvotes: 2
Views: 1052
Reputation: 175816
Using the designer give Choice
a single sub-item called mnuDynamic
, give it an index of 0
.
Loop the recordset loading new items:
Dim i as long
Do While rs_choice.EOF = False
If (i > 0) Then Load mnuDynamic(i)
mnuDynamic(i).Caption = rs_choice.Fields("column1").Value
rs_choice.MoveNext
i = (i + 1)
Loop
Upvotes: 4