简体   繁体   English

如何将ToolStripSplitButton添加到Visual Studio Toolbox?

[英]How to add ToolStripSplitButton to Visual Studio Toolbox?

I am using Visual Studio 2010, and I have come across a need to use the ToolStripSplitButton button. 我正在使用Visual Studio 2010,并且我遇到了使用ToolStripSplitButton按钮的需要。 I figured out from the reference material that ToolStripSplitButton is a form found under the System.Windows.Forms. 我从参考资料中发现ToolStripSplitButton是在System.Windows.Forms下找到的一个表单。

When I attempt to add this to my toolbox to try to use, I am unable to find ToolStripSplitButton, does anybody know how I can add this to my Visual Studio 2010 so I can use it? 当我尝试将其添加到我的工具箱中尝试使用时,我无法找到ToolStripSplitButton,是否有人知道如何将其添加到我的Visual Studio 2010中以便我可以使用它? I don't care if it's not in the toolbox, I just want to make sure the assembly reference is present so I can actually use it. 我不在乎它是否不在工具箱中,我只是想确保程序集引用存在,所以我可以实际使用它。

在此输入图像描述

It's inherited from and dependent on ToolStripDropDown so you can't use it as a stand-alone control. 它继承自ToolStripDropDown并依赖于ToolStripDropDown,因此您无法将其用作独立控件。 You can use it as a child control for ToolStripDropDown. 您可以将它用作ToolStripDropDown的子控件。

ToolStripSplitButton can be used only as ToolStripItem of a ToolStrip (contained in ToolStrip.Items ). ToolStripSplitButton只能用作ToolStripItemToolStrip (包含在ToolStrip.Items )。 It's designed so that you can't use it as a normal control. 它的设计使您无法将其用作普通控件。 It doesn't have a Parent property, and I guess it also doesn't have a Handle property. 它没有Parent属性,我猜它也没有Handle属性。 The inheritance tree is: 继承树是:

ToolStripSplitButton
   -> ToolStripDropDownItem
       -> ToolStripItem
          -> Component
             -> ...

Normally, you have to add some ToolStrip to host ToolStripSplitButton . 通常,您必须添加一些ToolStrip来托管ToolStripSplitButton

If you want to use code, here is a simple example: 如果你想使用代码,这是一个简单的例子:

ToolStrip toolStrip1 = new ToolStrip();
ToolStripSplitButton splitButton1 = new ToolStripSplitButton("Hi there"){Owner = toolStrip1};
//you can add items to ToolStripSplitButton via ToolStripSplitButton.DropDownItems

More info ToolStripSplitButton 更多信息ToolStripSplitButton

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM