按键 [英] KeyPress

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

问题描述

我正在制作一个程序,我想知道如何制作它,如果我点击F1按钮1打开,如果我再次点击F1按钮关闭

解决方案

使用功能按钮与使用
按钮类
 文本功能 ButtonBase.UseMnemonic properties y" ; true
如果前面带有符号(&)的第一个字符用作控件的助记键;否则,
false 。默认值为 true 。"并允许您分配

text
前面加上&符号,这样文本的第一个字符就会点击按钮。


我不知道你为什么要按住按钮,取消点击事件,然后将其关闭,因为这不是控件的标准。使用If语句或其他东西可以更简单地识别像If Button1.Backcolor
= Color.LimeGreen然后Button1.BackColor = Color.Red(以及其他任何事情),否则Button1.BackColor = Color.LimeGreen (并做其他任何事情)并在LimeGreen(On)和Red(Off)之间切换按钮颜色(反之亦然),这样当按钮背面颜色为LimeGreen时,
会不断运行,当它是红色时也许


im making a program and i was wondering on how to make it if like i hit F1 button1 turns on and if i hit F1 again the button turns off

解决方案

Using Function buttons is different than using the Button classes text ability with the ButtonBase.UseMnemonic property which "true if the first character that is preceded by an ampersand (&) is used as the mnemonic key of the control; otherwise, false. The default is true." and allows you to assign the text preceded with an ampersand so that the 1st character of the text will make the button click.

I do not know why you would want to hold a button on, voiding the click event, and then turn it off later as that is not the standard for the control. It would be simpler to use an If statement or something to discern something like If Button1.Backcolor = Color.LimeGreen then Button1.BackColor = Color.Red (and whatever else to do) else Button1.BackColor = Color.LimeGreen (and do whatever else to do) and toggle the buttons backcolor between LimeGreen (On) and Red (Off) (or vice versa) such that something will run constantly when the buttons backcolor is LimeGreen or not when it is Red maybe.


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

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