gpt4 book ai didi

c# - 在设计工具箱中找不到 ToolStripDropDownButton

转载 作者:行者123 更新时间:2023-11-30 23:33:42 43 4
gpt4 key购买 nike

我正在制作一个表单并想使用 ToolStripDropDownButton(基本上是一个带有向下箭头的按钮,您可以从那里选择一个项目):

as found in the Microsoft website但我似乎无法在表单 [设计] 工具箱中找到它。

我使用的是 VS2015 C# 社区版,net framework 4.6。我尝试添加命名空间 using System.Windows.Forms.ToolStripDropDownButton; 但它无法识别 toolstripdropdownbutton。对此有任何帮助,我们将不胜感激。谢谢。

最佳答案

您的代码中的问题是因为 System.Windows.Forms.ToolStripDropDownButton 是一个类,而不是命名空间。

Any idea how I can use that class to create the toolstripdropdownbutton control?

使用代码:

var item = new ToolStripDropDownButton("SomeText");
item.DropDownItems.Add(new ToolStripMenuItem("SubMenu1"));
item.DropDownItems.Add(new ToolStripMenuItem("SubMenu1"));
this.toolStrip1.Items.Add(item);

您还可以查看下面的构造函数以添加图像和事件处理程序,并在文档页面底部查看更多示例:

结果:

enter image description here

使用设计器:

您可以在表单上放置一个ToolStrip,然后点击添加项目的下拉菜单。然后选择 DropDownButton

enter image description here

更多信息:

关于c# - 在设计工具箱中找不到 ToolStripDropDownButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33823819/

43 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com