|
-
Oct 24th, 2003, 01:56 PM
#1
Thread Starter
New Member
Responding to Menu click event
I have a 'History' menu on the main menu in myformapp. When the form loads, the menu is populated with menuitems that come from text stored in an array of strings, sCommandArray().
The menu is populated using a for loop:
For iCounter = 0 To sCommandArray.GetUpperBound(0)
.m_mnuCommandHistory.MenuItems.Add(sCommandArray(iCounter), New EventHandler(AddressOf CommandHistoryClick))
next
The text of each menuitem is the contents of an array element.
The event handler, CommandHistoryClick, is declared as follows:
Private Sub CommandHistoryClick(ByVal Sender As system.object, ByVal e As System.EventArgs) Handles m_mnuCommandHistory.Click
End Sub
How do I determine which menuitem is the sender? I want to populate a text box with whichever menuitem is selected.
-
Oct 24th, 2003, 04:10 PM
#2
try something like this...
VB Code:
[COLOR=blue]Private Sub[/color] CommandHistoryClick([COLOR=blue]ByVal[/color] Sender [COLOR=blue]As[/color] system.object, [COLOR=blue]ByVal[/color] e [COLOR=blue]As[/color] System.EventArgs) [COLOR=blue]Handles[/color] m_mnuCommandHistory.Click
[COLOR=blue]Dim[/color] Mi [COLOR=blue]As[/color] MenuItem = [COLOR=blue]DirectCast[/color](Sender,MenuItem)
[COLOR=blue]If[/color] Mi.Text = "the text of your menu item" [COLOR=blue]Then[/color]
[COLOR=green]'/// Do Stuff here.[/color]
[COLOR=blue]End If[/color]
[COLOR=blue]End Sub[/color]
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|