[.net] How to change button appearance?

Started by
11 comments, last by gharen2 16 years, 2 months ago
I need to change button appearance after it was clicked. Before I click, it is Standard style but after clicked, it became flat. The purpose of this is as an indicator so that users recognize that they has clicked the button. How to do that? Thank you very much..
Advertisement
You could just have a variable to hold the state of the button. Then in it's Button_Click() event toggle it and set the button style based on the value.

butState = !butState;if(butState)   Button.Flatstyle = Flatstyle.Flat;else   Button.Flatstyle = Flatstyle.Standard;

Ok, thank you very much.
Quote:Original post by chrisliando
The purpose of this is as an indicator so that users recognize that they has clicked the button.

Just my opinion, but using such a non-standard method is stupid. There's enough crappy software out there without adding more.

Former Microsoft XNA and Xbox MVP | Check out my blog for random ramblings on game development

Do you have any idea of how to do this in the best manner?

If you do have, I will try that.

Thank you very much.
Why do you think you need to let a user know he's clicked the button. Don't you think he'll figure it out himself? [rolleyes]

Former Microsoft XNA and Xbox MVP | Check out my blog for random ramblings on game development

Once again, this is a request from my Senior. But it is easy compared to displaying active cursor on 2 textBoxes at the same time.

The purpose is to make the application more friendly.

Thank you.
That's not making the application more friendly. I'd think there was a bug in it if I saw it do that.

Former Microsoft XNA and Xbox MVP | Check out my blog for random ramblings on game development

If you want a control that looks like a button but can be programatically set to look like it has been pressed, you could use a Checkbox with its Appearance property set to Button.

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Quote:Original post by Headkaze
You could just have a variable to hold the state of the button. Then in it's Button_Click() event toggle it and set the button style based on the value.

butState = !butState;if(butState)   Button.Flatstyle = Flatstyle.Flat;else   Button.Flatstyle = Flatstyle.Standard;


bear in mind that with such an approach, although the button will change style to show it has been clicked, it will still be clickable.

If you are doing this to stop the user from clicking it twice, then you may also want to look at setting the button to disabled. Note that doing this will also change the appearance of the button, so simply doing this and not changing its style may be enough.
Gavin Coates
[size="1"]IT Engineer / Web Developer / Aviation Consultant
[size="1"][ Taxiway Alpha ] [ Personal Home Page ]

This topic is closed to new replies.

Advertisement