如何在C#中使按钮处于按下状态? [英] How can I make a button to be in pressed state in C#?

查看:1301
本文介绍了如何在C#中使按钮处于按下状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我按下按钮时我希望它保持按下状态,直到我再次按下按钮。

如何在C#中执行此操作?



谢谢!

When I press a button I want it to stay in pressed state untill I'll press the button again.
How can I do it in C#?

Thanks!

推荐答案

如果你使用的是Windows Forms,你可以使用 CheckBox 外观属性设置为按钮



Nick
If you're using Windows Forms, you can use a CheckBox with the Appearance property set to Button.

Nick


它有效!

我使用CheckBox,将Appearance属性设置为Button,这正是我想要的。

但是为什么按钮的尺寸这么小?

我无法改变按钮的高度和重量?为什么?
It works!
I used a CheckBox with the Appearance property set to Button and it's exactly what I wanted.
But why the size of the button is so small?
I can not change the height and the weight of the button? Why?


你想用它实现什么?如果你想切换一些东西可以有办法做到这一点。



如果是关于按下按钮...你也可以使用css或javascript来做到这一点。有点像,点击一次按钮控制,只要没有收到响应,它就会被按下。现在在你的情况下,保持按下它的逻辑是什么?
What is that you want to achieve using this? If you want to toggle something there can be ways to do it.

If it's about showing the button pressed... you can do that too using css or javascript. Something like, Click once button control, it will be pressed as long as response is not recieved. Now in your case, what is the logic of keeping it pressed?


这篇关于如何在C#中使按钮处于按下状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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