user225269
user225269

Reputation: 10893

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?

Upvotes: 1

Views: 6127

Answers (4)

user1037880
user1037880

Reputation:

To highlight a button you have to use two buttons.

  1. a button with red in color (example-red_button)
  2. a button with faded red in color(example-faded_red_button,visible as false)

Place one above the other.

On the mouse down event of the red_button:

red_button.sendtoback
faded_red_button.bringtofront
faded_redb_button.visible=true

On the mouse up event of the red_button:

faded_red_button.sendtoback
red_button.bringtofront
red_button.visible=true

Upvotes: 0

Steve Danner
Steve Danner

Reputation: 22168

If this is WPF or Silverlight, you can simply re-template the Button control, and change the "Normal" state to match the "MouseOver" state. Not sure what you're using though?

Upvotes: 1

Hans Passant
Hans Passant

Reputation: 942257

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.

Upvotes: 1

Javier
Javier

Reputation: 4141

I don't know exactly why do you need this behaviour, but maybe you could use another control instead of Button. You could use CheckBox, with the appearance of a button. 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 :-)

Upvotes: 2

Related Questions