G
Guest
Hi all,
I have a simple form with:
1 TextBox
1 Checkbox
1 Button
I have coded the validate events as follows:
private void textBox1_Validating(object sender,
system.ComponentModel.CancelEventArgs e)
{
e.Cancel=true;
textBox1.Focus();
}
private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("Button");
}
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{
MessageBox.Show("Checkbox");
}
For the purpose of this example I always cancel the validating event. But
the behaviour I see suggests the events dont actually get cancelled. ie.
Focus in the textbox, change its content, click the checkbox. The checkbox
becomes checked/unchecked and you get the checkbox message. Do the same then
click the button, you still get the buttons message. However focus doesn't
leavr the textbox???
I though the idea behind setting the cancel event arguements was to stop
further processing until a valid input has been made.
Please advise.
Pete.
I have a simple form with:
1 TextBox
1 Checkbox
1 Button
I have coded the validate events as follows:
private void textBox1_Validating(object sender,
system.ComponentModel.CancelEventArgs e)
{
e.Cancel=true;
textBox1.Focus();
}
private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("Button");
}
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{
MessageBox.Show("Checkbox");
}
For the purpose of this example I always cancel the validating event. But
the behaviour I see suggests the events dont actually get cancelled. ie.
Focus in the textbox, change its content, click the checkbox. The checkbox
becomes checked/unchecked and you get the checkbox message. Do the same then
click the button, you still get the buttons message. However focus doesn't
leavr the textbox???
I though the idea behind setting the cancel event arguements was to stop
further processing until a valid input has been made.
Please advise.
Pete.