单击PropertyGrid中的属性时如何获取控件以执行自定义功能 [英] How to get control to do customized function when click property in PropertyGrid

查看:80
本文介绍了单击PropertyGrid中的属性时如何获取控件以执行自定义功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,PropertyGrid中有"Color"属性,当用户单击属性的"value"项末尾的图标时,PropertyGrid对象将自动支持该"Color"的专用颜色对话框'属性,供用户编辑颜色数据.

我的问题是:

< 1>单击此图标时如何获得控件,以便可以打开ColorDialog而不是内置的颜色对话框?

< 2>通常,我想在单击此图标(例如Boolean属性,Font属性等)时获取控件,任何人都可以提供任何解决方案或详细的参考代码吗?谢谢.

Normally, there is ''Color'' property in PropertyGrid, when user click the icon at the end of ''value'' item of property, the PropertyGrid object will automatically support the dedicated color dialog for this ''Color'' property for user to edit the color data.

My questions are :

<1> How can I get the control when clicking this icon, so that I can open the ColorDialog instead of the build-in color dialog ?

<2> In general, I would like to get the control when clicking this icon for such as Boolean property, Font property etc., can anyone provide any solution or detailed reference code ? Thanks.

推荐答案

我已经回答了一个类似的问题.这不容易,但是可行.请参阅此问题和我的答案:如何在单击时获得响应PropertyGrid [ ^ ]. (请参阅我的长"答案.)

乍一看,请不要说我的答案无关紧要:虽然很相关,但是PropertyGrid的意识形态可能与您期望的有很大不同.如果使用此控件,则不会修改行为.相反,您应该创建自己的控件以嵌入到网格中.要使用它们,您需要创建一种特殊的数据类型来包装您的真实数据.您应该将包装器数据类型的实例分配给属性PropertyGrid.Selected对象,而不是引用真实"数据对象.

不过,这种方法可能非常通用:您可以开发自定义控件和包装器,以适应几乎所有需要的数据类/结构.不要以为您需要为每种特定的数据类型重复这项工作.

—SA
I already answered a similar Question. This is not easy, but doable. Please see this Question and my Answer: How to get response when click PropertyGrid[^]. (See my "long" Answer.)

Please don''t say my Answer is irrelevant from the first glance: it is relevant, but the ideology of PropertyGrid is maybe very different from what you might expect. The idea is not modifying the behavior if this control. Instead, you should create you own control(s) to embed in the grid. To use them, you need to create a special data type to wrap your real data. You should assign an instance of your wrapper data type to the property PropertyGrid.Selected object instead of reference to your "real" data object.

Nevertheless, this approach can be very universal: you can develop your customized controls and the wrapper the way it will suite nearly all data classes/structures you need. Don''t think you need to repeat this work for every specific data type.

—SA


这篇关于单击PropertyGrid中的属性时如何获取控件以执行自定义功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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