C# WinForms 中的切换按钮 [英] ToggleButton in C# WinForms

查看:38
本文介绍了C# WinForms 中的切换按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 C# WinForms 中创建切换按钮?我知道您可以使用 CheckBox 控件并将其 Appearance 属性设置为Button",但它看起来不正确.我希望它在按下时看起来凹陷,而不是平坦的.有什么想法吗?

Is it possible to create a toggle button in C# WinForms? I know that you can use a CheckBox control and set it's Appearance property to "Button", but it doesn't look right. I want it to appear sunken, not flat, when pressed. Any thoughts?

推荐答案

我最终覆盖了 OnPaint 和 OnBackgroundPaint 事件,并完全按照我的需要手动绘制了按钮.效果很好.

I ended up overriding the OnPaint and OnBackgroundPaint events and manually drawing the button exactly like I need it. It worked pretty well.

这篇关于C# WinForms 中的切换按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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