如何找出主题 WinForms 控件的基于主题的属性值?一般用于 DevExpress 或 WinForms
我正在 DevExpress.XtraEditors 上下文中处理这个问题,但也许答案也适用于 WinForms 控件使用主题的其他情况。
基本上,我如何找出主题控件具有哪些属性设置集合?有没有办法让我看看主题定义?另外,我可以动态地查看这些设置,即在执行期间从应用程序内部查看(就像我可以在执行期间打印出无主题的 Appearance.BackColor 一样)?
I am dealing with this issue in DevExpress.XtraEditors context, but maybe the answer would also apply to other situations where themes are used for WinForms controls.
Basically, how do I find out what collection of property settings does a themed control have? Is there a way for me to go look at the theme definition? Also, can I look at these settings dynamically, i.e. from within the app during execution (much like I can print out unthemed Appearance.BackColor during execution)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定您在寻找什么,但如果您有兴趣查找所有控件(或控件
Type
)的“外观”属性,您可以使用 TypeDescriptor.GetProperties 方法。此方法返回 PropertyDescriptorCollection您可以从中选择带有CategoryAttribute.Appearance
属性的属性。您可以在控件的实例上使用此方法:
或者,在控件
Type
上使用此方法:但是一旦获得
PropertyDescriptorCollection
,您就可以测试CategoryAttribute 是否存在.Appearance
(这意味着该属性出现在控件的“外观”部分 - 假设 Browsable == true),如下所示:I'm not certain what you're looking for, but if you're interested in finding all of a control's (or control
Type
's) 'Appearance' properties you can use the TypeDescriptor.GetProperties method. This method returns a PropertyDescriptorCollection from which you can pick out the properties with theCategoryAttribute.Appearance
property.You can use this method on an instance of the control:
Or, on a control
Type
:But once you get a
PropertyDescriptorCollection
you can test for the presence ofCategoryAttribute.Appearance
(which means the property appears in the control's 'Appearance' section - assuming Browsable == true) like this: