Dropdown Form menu. How to find the tree that the sselected item is from

  • Thread starter Thread starter Robert Brown
  • Start date Start date
R

Robert Brown

Hi There..

I have a Windows App with a menu. The menu is dynamically created at
runtime. This is working perfectly, except.....

I have serveral menus under the one parent. Under each of these menus,
there could be menu items with the same text. Of course, when I click
the menu item that I want I get the selected text returned to me. Ok..
this is fine, but if the actual menu item I select is not the first
one with the same text, how do I know the exact one I selected?

example:

Reports
|
--- Dec-03
| |-> Report 1
| |-> Report 2
|
--- Jan 04
|-> Report 1
|-> Report 2

So in the above example, if I/user selects Report 2 of Jan 04, the
select text that is return is "Report 2". How do I find out if that is
belonging to Dec 03 or Jan 04? The selected text is used to match the
Database to find the report to run, but in the above example, I always
get the DEC 03 Report 2. It would be good if I could find the
childmenu name (DEC 03 or JAN 04) as well...

This is the statement I use to get the selected item

Public Sub MenuClick(ByVal sender As Object, ByVal e As EventArgs)
Dim sSelected as string = CType(sender, MenuItem).Text()

........Blah Blah Blah

End Sub

Any ideas, code examples..

Thanks,
Robert
 
Hi Robert,

Try what this very simple and logical sentence can do for you

Dim myItem As String = _
DirectCast(DirectCast(DirectCast(sender, MenuItem).Parent, Menu),
MenuItem).Text

:-))

Cor
 
Back
Top