C# 如何使按钮看起来好像被按下?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4913/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make a button appear as if it is pressed?
提问by Douglas Tosi
Using VS2008, C#, .Net 2 and Winforms how can I make a regular Button look "pressed"?
Imagine this button is an on/off switch.
ToolStripButton
has the Checked property, but the regular Button does not.
使用 VS2008、C#、.Net 2 和 Winforms 如何使常规按钮看起来“按下”?想象一下这个按钮是一个开/关开关。
ToolStripButton
具有 Checked 属性,但常规 Button 没有。
采纳答案by Tanerax
One method you can used to obtain this option is by placing a "CheckBox" object and changing its "Appearance" from "Normal" to "Button" this will give you the same functionality that I believe you are looking for.
您可以用来获得此选项的一种方法是放置一个“CheckBox”对象并将其“外观”从“正常”更改为“按钮”,这将为您提供我相信您正在寻找的相同功能。
回答by Mark Cidade
You could probably also use the ControlPaint class for this.
您可能也可以为此使用 ControlPaint 类。
回答by Chris Hughes
I think you may need a ToggleButton
. You can take a look at third party vendors of WinForms components such as Telerik, DevExpress, ComponentFactory, ViBlend which provide such control. They all provide toggle buttons.
我想你可能需要一个ToggleButton
. 您可以查看提供此类控制的 WinForms 组件的第三方供应商,例如 Telerik、DevExpress、ComponentFactory、ViBlend。它们都提供切换按钮。