禁用控制权变动TEXTCOLOR [英] Change TextColor of disabled control

查看:99
本文介绍了禁用控制权变动TEXTCOLOR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何改变文本的颜色,当控制disabled.I要设置控制时,在C#中的WinForms禁用不同的颜色。

How to change the color of text, when a control is disabled.I want to set different color when control is disabled in c# winforms.

推荐答案

编辑:我已经犯了同样的错误,因为科迪的意见,以便纠正我的答案

I had made the same mistake as Cody in the comments so corrected my answer.

这取决于它控制它。

例如,如果它是一个文本框也许你可以把它只读,而不是禁止。而对于其他一些控件,你也许可以做类似的事情,使他们会被禁用,而无需实际被禁用。

For example, if it's a TextBox maybe you could make it ReadOnly instead of disabled. And for some other controls you might be able to do similar things to make them appear disabled without actually being disabled.

不过,如果你想要做正确,你需要让他们重绘或重写OnPaint事件,并自己绘制的文本。

However, if you want to do it properly you need to make them Owner-draw or override the OnPaint event and draw the text yourself.

这篇关于禁用控制权变动TEXTCOLOR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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