简体   繁体   English

如何突出显示在vb.net中单击的按钮

[英]How to highlight a button that is clicked in vb.net

Highlight, just like when you hover over to the button, its being highlighted. 突出显示,就像当您将鼠标悬停在按钮上时,它会突出显示。 But how do you retain the highlight when you have clicked the button? 但是,当您点击按钮时,如何保留亮点?

I don't know exactly why do you need this behaviour, but maybe you could use another control instead of Button. 我不知道为什么你需要这种行为,但也许你可以使用另一个控件而不是Button。 You could use CheckBox, with the appearance of a button . 你可以使用CheckBox,带有按钮的外观 You can change this appearance in the properties window of the checkbox. 您可以在复选框的属性窗口中更改此外观。

If you don't want to use this option, just let me know :-) 如果您不想使用此选项,请告诉我:-)

It is not much of a functional spec. 这不是一个功能规范。 When it is supposed to turn off? 什么时候应该关掉? Anyhoo, use a CheckBox, set Appearance = Button, AutoSize = False, TextAlign = MiddleCenter. Anyhoo,使用CheckBox,设置Appearance = Button,AutoSize = False,TextAlign = MiddleCenter。

If this is WPF or Silverlight, you can simply re-template the Button control , and change the "Normal" state to match the "MouseOver" state. 如果这是WPF或Silverlight,您可以简单地重新模板Button控件 ,并更改“正常”状态以匹配“MouseOver”状态。 Not sure what you're using though? 不确定你在使用什么?

To highlight a button you have to use two buttons. 要突出显示按钮,您必须使用两个按钮。

  1. a button with red in color (example-red_button) 一个红色的按钮(example-red_button)
  2. a button with faded red in color(example-faded_red_button,visible as false) 一个褪色红色的按钮(example-faded_red_button,可见为false)

Place one above the other. 将一个放在另一个之上。

On the mouse down event of the red_button: 在red_button的鼠标按下事件:

red_button.sendtoback
faded_red_button.bringtofront
faded_redb_button.visible=true

On the mouse up event of the red_button: 关于red_button的鼠标注册事件:

faded_red_button.sendtoback
red_button.bringtofront
red_button.visible=true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM