I have made a toolbar with some buttons inside in c# and I am trying to make these button remain pressed while I first click on the and unpressed during my second click on them.
Any suggestion?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Abhimanyu K VatsaPosted May 2, 2011, 8:09 AM
if you want to change the button appearence then you have to use some another method from outside.
for this use two images, one looks like pressed button and another like released button (up). and then use if...else condition in code-behind to switch between them.
hope this helps
FroglegPosted May 1, 2011, 5:08 PM
public partial class Form1 : Form
{
bool bttnclicked = false;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
toolStripButton1.BackColor = Color.Green;
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
if (!bttnclicked)
{
toolStripButton1.BackColor = Color.Red;
bttnclicked = true;
}
else
{
toolStripButton1.BackColor = Color.Green;
bttnclicked =false;
}
}
}
Michael OmmerPosted May 1, 2011, 3:35 PM
Kirtan PatelPosted May 1, 2011, 10:30 AM