I'm building menus in code from a database. How do I
determine which menu item was selected? Does the
System.EventArgs contain this? If so, what property?

Here's the declaration:

Private Sub Menu_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Click


Thanks!

Re: Select MenuItem Question by froeschlin

froeschlin
Fri Aug 22 02:32:40 CDT 2003

mCompany wrote:
> I'm building menus in code from a database. How do I
> determine which menu item was selected? Does the
> System.EventArgs contain this? If so, what property?
>
> Here's the declaration:
>
> Private Sub Menu_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles MyBase.Click

How is the menu constructed? What is the base class here?
Typically, the click event comes from the MenuItem, not the
Menu, in which case the sender object is the MenuItem.


Re: Select MenuItem Question by Herfried

Herfried
Fri Aug 22 06:28:03 CDT 2003

Hello,

"mCompany" <nospam@mvestcapital.com> schrieb:
> I'm building menus in code from a database. How do I
> determine which menu item was selected? Does the
> System.EventArgs contain this? If so, what property?
>
> Here's the declaration:
>
> Private Sub Menu_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles MyBase.Click

Where do you add the code?

Do you add handlers by using AddHandler? You will get a reference to the
MenuItem in the sender parameter.

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet



Re: Select MenuItem Question by Herfried

Herfried
Fri Aug 22 07:45:31 CDT 2003

Hello,

"mCompany" <mail@mcompany.com> schrieb:
>I am using AddHandler:
>
>AddHandler menuItem.Click, AddressOf Me.MenuItem1_Click
>
>However, what is the syntax for determining which menu
>item as selected? Which EventArgs are used to determine
>the actual item that was clicked?

Try this:

\\\
MsgBox(DirectCast(sender, MenuItem).Text)
///

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet