如何修改 vb.net 中禁用按钮的外观?

发布于 2024-08-19 03:18:05 字数 164 浏览 1 评论 0原文

我在 vb.net 中禁用了一个按钮,当我这样做时,我无法控制 BackColor 或 ForeColor 属性来更改外观。我为它们设置了新值,但它们没有被采纳。禁用按钮看起来几乎与我的启用按钮一模一样,因此您无法分辨出区别。我正在使用平面样式按钮,但尝试更改它,但它似乎仍然不起作用。有什么技巧可以做到这一点吗?

I'm disabling a button in vb.net and when I do, I cannot control the BackColor or ForeColor properties to change the appearance. I set new values for them but they don't get picked up. The disabled button looks almost exactly like my enabled buttons so you can't tell the difference. I'm using Flat Style buttons, but have tried changing this and it still doesn't seem to work. Is there some sort of trick to be able to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽容 2024-08-26 03:18:05

我在 VB.NET 2008 中遇到了类似的问题。

当我在设计时将文本框的背景颜色设置为默认值以外的颜色时,当我在运行时禁用该文本框时,它并没有得到“禁用”的外观;背景颜色保持不变。
为了解决这个问题,我必须重写 OnEnabledChanged 方法并手动将背景设置为我需要的。

这与您遇到的问题有点不同,但我认为重写 OnEnabledChanged 方法可能会帮助您解决问题。

I ran into a similar problem in VB.NET 2008.

When I set the background color of a textbox to something other than the default at design time, then when I disabled that textbox at runtime, it did not get that 'disabled' look; the background color remained unchanged.
To get around this, I had to override the OnEnabledChanged method and manually set the background to what I needed.

This is a little different than the problem you have, but I think that overriding the OnEnabledChanged method might help you out.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文