4

I would like to use Combo Box in my WinForms application to select only one option out of many. This choice affects the whole application and is pretty important, so I don't want to use Menu Strip for this. Therefore Combo Box is the obvious choice.

There is one problem though, I have a two-level hierarchy of these choices and I need to select and display options from the second level. Put simply, I would like to obtain something like this:

enter image description here

Is there a way to do this or something similar easily using WinForms tools? Or some easy way to implement this? I haven't really implemented any visual controls in WinForms before and I don't want to waste a lot of time by learning how to. Thanks for any answer.

Community
  • 1
  • 1
SysGen
  • 604
  • 7
  • 29
  • 2
    What are your objections to `MenuStrip`? From what you've written and the image you show, it appears to be a better fit than a `ComboBox`. – adv12 Jun 25 '15 at 15:33
  • I would probably use two combo boxes for what you are trying to do. On selection change for the box, you would fill the second box with the choices appropriately. Otherwise I think you either need to create your own control or look into WPF. http://stackoverflow.com/questions/722700/wpf-treeview-inside-a-combobox – DoomVroom Jun 25 '15 at 15:36
  • @adv12 I don't want to use Menu Strip for this for reasons related to GUI design. It is acceptable (let's call it plan B :-)) but I would much rather see something like Combo Box. – SysGen Jun 25 '15 at 15:39
  • @DoomVroom I thought about two Combo Boxes, but that is not an ellegant solution (even using Menu Strip is more ellegant, but I'd like to avoid that either). – SysGen Jun 25 '15 at 15:41
  • If Winforms controls not desired, you can use controls created by third part, or use WPF controls in the winforms – Fabio Jun 25 '15 at 16:44

1 Answers1

0

For anybody that still needs this, you can use the ToolStrip with menu items to represent multilevel combo-boxes.

Attach click listeners to the ToolStripMenuItems and use OwnerItem to read the text of the parent.

Cj_Rodriguez
  • 459
  • 2
  • 4