添加按钮以控制属性 [英] Add a button to control properties

查看:125
本文介绍了添加按钮以控制属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在制作自己的用户控件,并有2个问题
1.我想在默认属性列表上添加一个按钮,并且我想在单击该按钮时打开模式窗体,
2.我想将控件属性归为一类(属性Category(...)不起作用,因为我发现它仅适用于我添加的属性网格).

这是完全可能的,但并不容易;您将写几件事以允许在PropertyGrid中进行自定义编辑.我认为模态形式不是一个好主意,因为您可以通过提供自定义的就地编辑器来做得更好.但是,也可以使用模式形式:内联编辑器将是您想要的按钮;然后此按钮将显示您的模态形式.

我试图在此处描述有关此主题的路线图:如何单击PropertyGrid时获得响应 [ ^ ].

同样,这并不容易,所以对不起我无法为您的案例专门开发代码.这将远远超出CodeProject问题与答案的格式.您可以找到主意,转到我在答案"中列出的类型的帮助页面,并编写自己的代码,是否以及何时遇到任何其他问题,请提出另一个问题.

另请参阅:在从组合框中获取文本框. [ UITypeEditor [ ExpandableObjectConverter [此处是使用其中大多数示例的链接. [我对此有何想法 < pre =" cs" < /pre >


Hi,
i''m making my own user control and have 2 questions
1. i want to add a button on default properties list and i want to open a modal form when that button is clicked,
2. i want to group my control properties in one category (the attribute Category(...) doesn''t work, as i found it works only with property grid added by me)

This is quite possible but not easy at all; you''ll to write several things to allow custom edit in the PropertyGrid. I think modal form is not a good idea as you can do much better by providing a custom in-place editor. However, a modal form is also possible: you in-line editor will be the button you want; and this button will show your modal form.

I tried to describe a road map on this topic here:
How to get response when click PropertyGrid[^].

Again, this is not easy, so I''m sorry I cannot afford developing code specially for your case. It would be far beyond the format of CodeProject Questions-and-Answers. You can get the idea, go to help pages on the types I list in my Answer and write your own code, ask another question if and when you face any problems.

See also: Setting value in textbox when it is taken from combobox..[^].

Good luck,
—SA


To achieve your aims you will probably have to write a UITypeEditor[^] and one or more ControlDesigners or one of its descendants and quite possibly one or more TypeConverters. From your description possibly an ExpandableObjectConverter[^].

Here is a link to an example that uses most of these.[^]


I thought something about this

<pre lang="cs">public Sometype PropertyName
{
   get
   {
      return SomeValue;
   }
   set
   {
     (new Form()).ShowDialog();
   }
}
</pre>


这篇关于添加按钮以控制属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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