Le 6 févr. 06, à 22:11, Chuck Pelto a écrit :
How would one go about doing a dim statement on the fly in an
application?
Situation: Building multiple menu items in a contextual menu and
multiple submenu items to go with said menu items, when the number of
menu items with submenus is variable.
Looking at the New ContextualMenu Build example, they've got just one
submenu. In there one has to dim the submenu and give it a name. This
is all well and good in hard-wiring code when one knows the number of
items that will have submenus, but what if any number of menu items
could have submenus associated with them?
It looks like one has to dim submenus as they come up. One can't just
use the statement...
dim submenu as new MenuItem("SubMenu")
....over and over again. One would lose anything that was built in any
previous 'submenu' items. Would they not?
So, what is to be done? I'm sure this issue has come up before, but
I'm unfamiliar with the solution.
When I tried RB2005, I created an application with a multicolumns
listbox. The user enters texts in some cells (like a menu: the left
column is the base menu; the second column is the submenu of the item
in left). When the user control-clicked a canvas, I built the menu
entered in the listbox.
Basically, I did so:
'"Base" is the parameter for the base menu item
dim n As MenuItem
n=new MenuItem
n.Enabled=True
n.Tag=j*1000+i 'Used to identify the menu; i and j are loop variables
n.Text=s(i) 'You know what to assign ;-)
base.append n
so, when you do "n=new MenuItem" for the second time, n is not
forgotten (it is kept in "base"). If you want to retrieve it, look for
an item with the tag you assigns.
I'm completely wrong, or you asked for something like that?
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>