[2.0] using 1 Button for 2 Functions[RESOLVED]
I need to get one Button to both Start and Stop...Now for some reason i cant remember this for the life of me..lol
But this is what i have I think its correct but i cant remember :ehh:
VB Code:
private void button1_Click(object sender, EventArgs e)
if (button1.Capture == true)
{
toolStripStatusLabel2.Text = " Sending Message";
timer1.Enabled = true
}
else
{
if(button1.Capture == false)
toolStripStatusLabel2.Text = "";
timer1.Enabled = false
}
}
Am i correct?? and is their a shorter version of this..lol :)
Re: [2.0] using 1 Button for 2 Functions
I'm not quite sure what the Capture property has to do with this. I would probably do it either of two ways. Using a regular Button:
Code:
// Toogle the timer state.
this.timer1.Enabled = !this.timer1.Enabled;
// Set the label text based on the timer state.
this.toolStripStatusLabel2.Text = this.timer1.Enabled ? "Sending Message" : string.Empty;
or else use a CheckBox with its Appearnce property set to Button. That way it looks exactly like a regular Button but with toggle functionality, so you'd handle its CheckChanged event:
Code:
this.timer1.Enabled = this.toggleButton1.Checked;
this.toolStripStatusLabel2.Text = this.toggleButton1.Checked ? "Sending Message" : string.Empty;
Re: [2.0] using 1 Button for 2 Functions
Thxs i prefer the first method ,dont really want a checkbox type... :)
1 Attachment(s)
Re: [2.0] using 1 Button for 2 Functions[RESOLVED]
Have a look at the screenshot to see what I meant. Both the controls you see are CheckBoxes with their Appearance property set to Button. RadioButtons have similar functionality.
Re: [2.0] using 1 Button for 2 Functions[RESOLVED]
yeah i see what you mean...I'm using Mouse Roll overs for different background colors,so i like the other way.. :) but that will be handy for some of the other buttons i have on my form..