PropertyGrid 中的斜体文本
我使用 PropertyGrid 来显示通过 ICustomTypeDescriptor 的实现公开的自定义属性。
我的对象设置在树结构中,每个属性的值要么在每个对象中设置,要么从父对象继承。 在 PropertyGrid 中,我想直观地向用户显示在所选对象中设置了哪些属性值,以及哪些属性值是从父对象继承的。
现在我将每个属性分为两类。 一组显示实际对象中设置的值,如果未设置,则显示空白字段。 另一组显示分配给对象的属性值,这些属性值要么在对象中设置,要么继承(如果未在对象中设置)。
我想将这两组合并为一组,以常规文本显示设置属性,并以斜体文本显示继承值。 但是,似乎没有任何方法可以通过 ICustomTypeDescriptor.GetProperties() 来做到这一点。 而且我无法轻松访问 PropertyGrid 的属性,因为它们是在程序运行时创建的。
I'm using a PropertyGrid to show custom properties that are exposed through the implementation of ICustomTypeDescriptor.
My objects are setup in a tree structure and values for each property are either set in each object or inherited from parent objects. In the PropertyGrid I want to visually show the user what properties values are set in the selected object, and which are inherited from parent objects.
Right now I am showing every property it two categories. One set shows what the value is set to in the actual object, with a blank field if it not set. The other set shows the property values assigned to the object that are either set in the object, or inherited if not set in the object.
I would like to combine these two groups into one buy showing set properties in regular text, and inherited values in italic text. However, there doesn't seem to be any way to do that through ICustomTypeDescriptor.GetProperties(). And I don't have easy access to the properties of the PropertyGrid since they get created while the program is running.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你不能使用斜体 - 但你可以使用粗体; 粗体行为由
PropertyDescriptor
的ShouldSerializeValue
确定; 您可以通过各种System.ComponentModel
技巧(ICustomTypeDescriptor
、TypeConverter
或TypeDescriptionProvider
包装PropertyDescriptor
code>) 并提供您自己的PropertyDescriptor
。或者,还有类似的网格,具有更多选项,例如 VisualHint - 请参阅“该页面上的“属性定制”。
You can't do italics - but you can do bold; the bold behaviour is determined by the
PropertyDescriptor
'sShouldSerializeValue
; you can wrapPropertyDescriptor
s via variousSystem.ComponentModel
tricks (ICustomTypeDescriptor
,TypeConverter
orTypeDescriptionProvider
) and provide your ownPropertyDescriptor
.Alternatively, there are similar grids with more options, such as by VisualHint - see "Property customization" on that page.