Cannot Get MenuItem's name[Notsolved]

A

Agnes

I understand that Name is not the property of Menuitem.
I try the following web site provide by Mick
There's a MenuExtender example on my site that adds a Tag and RadioGroup
property to menuitems.
You will find source in both VB and C#
http://dotnetrix.co.uk/menus.html

I know how to fill the property now, HOWEVER, During Form load, How can I
get that menuitem's Tag property??
I try .Me.newmenuItem.XXX <-- There is no such property in coding ??
Please help
 
C

Cor Ligthert

Agnes,

There is no menuitem.tag
http://msdn.microsoft.com/library/d...lrfsystemwindowsformsmenuitemmemberstopic.asp

Therefore the only thing I can come up to is to create your own menuitem
class. I made a little sample for you.

\\\Needs only a blanco application and pasting this in.
Friend WithEvents MainMenu1 As MainMenu
Friend WithEvents MenuItem1 As MenuItemAgnes
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
MainMenu1 = New MainMenu
MenuItem1 = New MenuItemAgnes
MainMenu1.MenuItems.Add(MenuItem1)
MenuItem1.Text = "Agnes"
MenuItem1.Tag = "Whatever"
Me.Menu = Me.MainMenu1
End Sub
Private Sub MenuItem1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MenuItem1.Click
MessageBox.Show(MenuItem1.Tag.ToString)
End Sub
End Class
Friend Class MenuItemAgnes
Inherits MenuItem
Private mTag As Object
Public Property Tag() As Object
Get
Return mTag
End Get
Set(ByVal Value As Object)
mTag = Value
End Set
End Property
End Class
///

I hope this helps a little bit?

Cor
 
M

Mick Doherty

Hi Cor,
Agnes was refering to the extended Tag property from my MenuExtender
example.

I answered this in other thread.
 
C

Cor Ligthert

Mick,

I was reading topdown, I saw later that there was already a long thread with
you involved, however than I had already made that sample and when you have
sent something you cannot correct that anymore.

I would have made another message when I had understood that in advance.

(You probably know the text from that already)

:)

Cor
 

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