[.NetFramework 4.0] I want to detect that a child item in the context menu has been clicked.

Asked 2 years ago, Updated 2 years ago, 93 views

Good morning.

Could you tell me about the subject matter?

VisualBasic (.NetFramework 4.0), VisualStudio 2010, Windows 7 (64Bit) dynamically generates and displays items from the context menu.

Some of the items on the menu have additional child items.

At this time, I am trying the ItemClicked event in ContextMenuStrip to detect that the item was selected, but it seems that the child item click cannot be detected in this event.

In this case, how do you detect clicks on all items (parent/child)?

Thank you for your cooperation.

.net vb.net

2022-09-30 20:56

1 Answers

You can add an event handler to the ToolStripMenuItem when you dynamically generate it using the AddHandler statement.

'Dim item As ToolStripMenuItem
AddHandler item.Click,AddressOfitem_Click

…

Private Subitem_Click (sender As Object, eAs EventArgs)
…
End Sub


2022-09-30 20:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.