Get a menu items tag

P

PetterL

I have in my program a menu that represent a setting set contained in a
array.
I planned to have the tag of each menutitem (0-4) to help the user to select
right setting.

How do i get the menuitems tag ?
I tried to go throu the menustrip1.dropdownitems.item but i cant get the tag
property
 
A

Armin Zingler

PetterL said:
I have in my program a menu that represent a setting set contained
in a array.
I planned to have the tag of each menutitem (0-4) to help the user
to select right setting.

How do i get the menuitems tag ?
I tried to go throu the menustrip1.dropdownitems.item but i cant get
the tag property


dropdownitems is not a property of a menustrip object. If you have one, the
Items property contains the items. Each item has it's Tag property. Example:

For Each item As ToolStripItem In menustrip1.Items
Debug.Print(item.Tag.ToString)
Next

But which object do you have and which information do you want to get? I
think it's not enumerating the Tag values.


Armin
 
P

PetterL

I have an menustrip with 2 menus called "File" and "Flash for"
Under "Flash for" i have 1-5 items, currently only two. Each subitem has the
..tag set 0 to 4 (now just 0 and 1 for two subitems. When clicked it i going
to have a sub routine to check if the tag is the same as the current one. If
not. the the tag is tellig the program to witch setting to switch to . It is
in a array that is loaded from a file at startup. This file has nothing to
do with the menu

"Flash for" menu will look someting like this
"Flash for"
"setting 1 " tag set to 0
"setting 2" tag set to 1
"setting 3" tag set to 2
 
A

Armin Zingler

PetterL said:
I have an menustrip with 2 menus called "File" and "Flash for"
Under "Flash for" i have 1-5 items, currently only two. Each subitem
has the .tag set 0 to 4 (now just 0 and 1 for two subitems. When
clicked it i going to have a sub routine to check if the tag is the
same as the current one. If not. the the tag is tellig the program
to witch setting to switch to . It is in a array that is loaded from
a file at startup. This file has nothing to do with the menu

"Flash for" menu will look someting like this
"Flash for"
"setting 1 " tag set to 0
"setting 2" tag set to 1
"setting 3" tag set to 2

So, you want to get the Tag of the clicked menu item? I'm still not sure
when and where you want to get the Tag. In the event handler...:

Private Sub TestToolStripMenuItem_Click( _
ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles TestToolStripMenuItem.Click

Debug.Print(DirectCast(sender, ToolStripMenuItem).Tag.ToString)

End Sub



Armin
 
P

PetterL

Currently it was not planned out well. since in the beginning i planned to
load menu item names from a file. But i had a few problems to get that one
to work so i created two items and read the tag to get setting for some
other part of the program.

The attempt to get help to the menu created from file is in the "Add menu
items in program" thread, I had a wacation at that time and when i answered
the interest in that thread was lost and i was stil stuck.




The main problem
 
A

Armin Zingler

PetterL said:
Currently it was not planned out well. since in the beginning i
planned to load menu item names from a file. But i had a few
problems to get that one to work so i created two items and read the
tag to get setting for some other part of the program.

The attempt to get help to the menu created from file is in the "Add
menu items in program" thread, I had a wacation at that time and
when i answered the interest in that thread was lost and i was stil
stuck.

Ok, well, how can I help you now?


Armin
 
P

PetterL

I think the tag problem i solved . I thin i also get another go at the other
problem another time so thanks for the help so far
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top