扩展系统控制-子类化控制类 [英] Extended system control-Subclassing Control class

查看:59
本文介绍了扩展系统控制-子类化控制类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从UserControl派生我的控件时,当我打开设计视图时,我能够添加控件并放置它们,就像我使用表单一样.如果我从现有的系统控件设计视图派生,则显示消息要向您的班级添加组件,请从工具箱中拖动它们,然后使用属性"窗口设置其属性.要为您的班级创建方法和事件,请单击此处切换到代码视图".如果将控件添加到此编辑器,它将显示为图标和文本.我无法将其放置在控件上.我想做的是从ToolStrip派生一个控件,并能够在查看器中添加和编辑toolstripitems.

When i open design view when my control is derived from UserControl i am able to add controls and position them just like i would with a form. if i derive from a existing system control design view displays the message "To add components to you class, drag them from the Toolbox and use the Properties window to set their properties. To create methods and events for you class, click here to switch to code view". If I add a control to this editor it appears as an icon and text. I cant position it over the control. What i am trying to do is derive a control from a ToolStrip and be able to add and edit toolstripitems in the viewer. Is this possible

推荐答案



我相信您在组件设计器中使用衍生的ToolStrip控件时遇到的问题是,"Controls"集合不是ToolStrip中的正确容器,(您将ToolStripItems添加到ToolStrip中的Items集合中,而不是其他控件的Controls集合)

有一种折衷方法:在设计器中查看自定义控件的属性,找到Items集合属性,然后单击其中带有三个点的按钮[...]

这将打开项目集合编辑器",并允许您直观地将ToolStripButtons,ToolStripLabels,ToolStripDropDownItems等添加到ToolStrip控件,但是它们不会在设计器画布上直观地显示.

希望这会有所帮助.

干杯,

西蒙.
Hi,

I believe the problem you are having with using a derivation of the ToolStrip control in the component designer, is that the ''Controls'' collection is not the correct container in a ToolStrip, (you add ToolStripItems to the Items collection in the ToolStrip, not the Controls collection like other controls)

There is a sort of compromise: view the properties of your custom-control in the designer, find the Items collection property, and click the button with three dots in it [...]

This opens the Items Collection Editor, and allows you to visually add ToolStripButtons, ToolStripLabels, ToolStripDropDownItems etc to the ToolStrip control, - they won''t however appear visually on the designer canvas.

Hope this helps.

Cheers,

Simon.


这篇关于扩展系统控制-子类化控制类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆