C# 属性:动态更改字体和颜色
有谁知道如何更改我输入的属性值的字体和字体颜色?我正在使用 Windows 窗体和 Propertygrid。谢谢。
我正在考虑使用: using( Font myFont = new Font("Arial", 8, FontStyle.Italic) )
但我不知道如何实现这个,我不知道如何改变文本的颜色。
Does anyone know how to change the font and the font color of the property value I am inputting? I am using Windows Forms and Propertygrid. Thank you.
I am thinking of using:using( Font myFont = new Font("Arial", 8, FontStyle.Italic) )
but am not sure how to implement this, and I am not sure how to change the color of the text.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
简而言之:使用 Microsoft PropertyGrid,您无法更改单个属性标签或值文本的颜色和字体。
Simply put: with the Microsoft PropertyGrid, you can't change the color and font of a single property label or value text.
您是否尝试更改 PropertyGrid 控件本身的字体和前景色,或者尝试更改在 PropertyGrid 中定义的两个属性的值?如果您创建了一个单独的类并将其设置为 SelectedObject,那么它应该像编辑该类一样简单。 充分利用 .NET Framework PropertyGrid 控件
填充 PropertyGrid 的类,您只需使用类中的构造函数或 DefaultValueAttribute 标记来设置所有默认值,然后再将其附加到 PropertyGrid。或者创建该类的一个实例,仅更改该实例所需的公共属性,然后附加它。
Are you trying to change the font and forecolor of the PropertyGrid control itself, or trying to change the values of two properties you've defined in the PropertyGrid? If you created a separate class and set it as the SelectedObject, then it should be as simple as editing the class. Getting the Most Out of the .NET Framework PropertyGrid Control
If you have a class that is populating the PropertyGrid, you could just use the constructor in the class or the DefaultValueAttribute tag to setup all your default values prior to attaching it to the PropertyGrid. Or create an instance of the class, change just those public properties you want for that instance, and then attach it.
我想这就是你要问的。
I think this is what you're asking.