我想创建一个如下图所示的ToolStripDropDownButton
但是当我尝试在工具箱中搜索ToolStripDropDownButton控件时,我无法找到它,因为经过一番谷歌搜索后,我发现它是一个 类 而不是 命名空间。
然后我用谷歌搜索了下面的代码
ToolStripDropDownButton dropDownButton1 = new ToolStripDropDownButton();
ToolStripDropDown dropDown = new ToolStripDropDown();
dropDownButton1.Text = "A";
dropDownButton1.DropDown = dropDown;
dropDownButton1.Height = 200;
dropDownButton1.Width = 200;
Set the drop-down direction.
dropDownButton1.DropDownDirection = ToolStripDropDownDirection.Left;
// Do not show a drop-down arrow.
dropDownButton1.ShowDropDownArrow = false;
Controls.Add((Control)dropDownButton1); //Doesn't work
但是最后一行代码无效并给出运行时错误
无法将类型“System.Windows.Forms.ToolStripDropDownButton”转换为“System.Windows.Forms.Control”
有人能告诉我如何在C# Windows 窗体中添加这样的按钮,或者我在代码中缺少什么吗?
平台:VS2008 Express(我知道它很旧)