Retrieving the Text property from nested ToolStripMenuItem DropDownItems

Feb 9 2009 1:48 PM

Dear Sirs: I am building an Outlook like application in C# and need a question answered please.
I have a WinForms application, with a ToolStripMenuItem containing 5-DropDownMenuItems and off of each of these 5-collections, I have additional subMenus or nested DropDownMenuItems.

I would like to be able to retrieve the Text property of any of the subMenu's, when they are clicked on.

For example, my first ToolStripMenuItem is named tsMnuItmFields1.

Off of this are my primary 5-subMenu's, or categories i.e.,

  • allMailFieldsToolStripMenuItem
  • allContactFieldsToolStripMenuItem
  • allAppointmentFieldsToolStripMenuItem
  • allTaskFieldsToolStripMenuItem
  • allNoteFieldsToolStripMenuItem

It is off of each of the above 5-DropDownMenu's that the nested collections of DropDownItems appear. For example, off of "allMailFieldsToolStripMenuItem", I have the following DropDownItems, "Bcc, Cc, Contacts, From, Importance" etc and I would like to be able to return (in code behind the scene) any of the Text properties of these individual menuItems when the user clicks on the subMenu.

I will be using the Text property in code to populate arrays of names for a ComboBox.

Can anyone please suggest how I can access these names, i.e., Text? When I attempt to return the name in code of one of the above 5-subMenu's, all I get is the name of that subMenu but not the collection of DropDownItems off of that menu.

I have tried searching the help file and the Internet but with no success.

Please help.
Thank you in advance.


Answers (9)