Drop down selection control
I have a nice little UserControl that is a draggable box with some text in. To the right hand side of the control is a little clickable arrow, which when clicked, I'd like to get a few options pop out of the right of the control.
I have already got a PopoutWindow class, which inherits ToolStripDropDown, which allows me to pop up get a new control to 'pop out' of the right hand side of this arrow with the following usage.
MyPopoutWindow options = new MyPopoutWindow ();
PopoutWindow popout = n开发者_StackOverflow中文版ew PopoutWindow(options);
popout.Show(arrowButton, arrowButton.Width, 0);
MyPopoutWindow is (currently) a custom UserControl, which I want to be the same as the popped-out body of a ComboBox, or a ToolStripMenu.
Does anyone know of a Winforms control I can use or inherit to get this effect? I've tried using ToolStripDropDownMenu
and ToolStripDropDown
but I get the following Exception:
Top-level control cannot be added to a control.
Thanks,
The solution was actually quite obvious (isn't it always!). As I mentioned in the question, I'd tried using a ToolStripDropDown
but that threw an Exception.
To solve this, I've got MyPopoutWindow
to inherit ToolStripDropDown
, but in the constructor, set the TopLevel
property to false. This worked!
public MyPopoutWindow()
{
TopLevel = false;
}
精彩评论