属性网格中如何有一个按钮?
我有一个属性网格,其中会引用一些属性。我希望属性网格中的其中一个项目是一个按钮,甚至有一个省略号按钮,它的作用就像普通获胜表单上的按钮一样。
有办法做到这一点吗?
提前感谢您的帮助!
I have a property grid that will have a few properties referenced. I would like to have one of the items in the property grid to be a button or even have a ellipses button which will act like a button on a normal win form.
Is there a way to do this?
Appreciate your help in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我建议阅读充分利用 .NET Framework PropertyGrid 控件。
它逐步介绍了如何为您的媒体资源创建自定义 UI,其中可能包括一个打开弹出窗口/单独表单/等的按钮。
I recommend reading Getting the Most Out of the .NET Framework PropertyGrid Control.
It walks through how to create a custom UI for your property, which could include a button that opens a popup/separate form/etc.
我使用扩展方法向 PropertyGrid 添加了全部折叠和展开所有按钮。
PropertyGrid 按钮
I added collapse all and expand all buttons to the PropertyGrid using extension methods.
PropertyGrid Buttons
UITypeEditor,使用 IWindowsFormsEditorService...就是这样。知道了!感谢您的指导!
UITypeEditor, using the IWindowsFormsEditorService... thats what it was. Got it! Thanks for the direction!
要执行它,您可以创建一个名称为
my_Button
的类,其中不包含任何项目,并在该类的顶部定义如下属性:用于执行该类的
UIEditor_List
类TypeConv_List
是它的名称,这些值可以定义如下:在项目类的最后一个
foreach
属性中,想要像这样定义按钮
propertygrid
定义事件名称propertyGrid1_PropertyValueChanged
并定义您想要执行的每个更改,如下所示:To perform it you can create a class like a name
my_Button
without any item in it and at the top of this class define attribute like this:UIEditor_List
class for performing of the class andTypeConv_List
is the name of it and these value can define as below:and at the last
foreach
property of your item class that want to be button define like thisand in the
propertygrid
define event namepropertyGrid1_PropertyValueChanged
and define every change you want to do like below: