N
Natalya.Pinsker
Hello,
In the Validating event of a TextBox, I am displaying a Yes/No message
box. If clicked on No, I cancel any subsequent events. This works
just fine. If clicked Yes, I want to go on. This doesn't work if I
click on a button (like a Save button). The focus stays with the Save
button after clicking Yes, but the click event for the Save button
doesn't fire.
I've pasted the condensed version of my code below. As a work around,
I tried setting "this.ActiveControl = this.ActiveControl;" but it had
no effect. This was suggested for a somewhat different problem by an
older post:
http://groups.google.com/group/micr...6a4d5900e11/8a8f5e8058e96ef0#8a8f5e8058e96ef0
private void txtQty_Validating(object sender,
System.ComponentModel.CancelEventArgs e)
{
if (Convert.ToInt32(txtQty.Text) == 0)
{
if (MessageBox.Show("Are you sure you want quantity set
to zero?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
== DialogResult.Yes)
{
//this.ActiveControl = this.ActiveControl;
}
else
{
e.Cancel = true;
}
}
}
I use VS2003.
Thanks.
In the Validating event of a TextBox, I am displaying a Yes/No message
box. If clicked on No, I cancel any subsequent events. This works
just fine. If clicked Yes, I want to go on. This doesn't work if I
click on a button (like a Save button). The focus stays with the Save
button after clicking Yes, but the click event for the Save button
doesn't fire.
I've pasted the condensed version of my code below. As a work around,
I tried setting "this.ActiveControl = this.ActiveControl;" but it had
no effect. This was suggested for a somewhat different problem by an
older post:
http://groups.google.com/group/micr...6a4d5900e11/8a8f5e8058e96ef0#8a8f5e8058e96ef0
private void txtQty_Validating(object sender,
System.ComponentModel.CancelEventArgs e)
{
if (Convert.ToInt32(txtQty.Text) == 0)
{
if (MessageBox.Show("Are you sure you want quantity set
to zero?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
== DialogResult.Yes)
{
//this.ActiveControl = this.ActiveControl;
}
else
{
e.Cancel = true;
}
}
}
I use VS2003.
Thanks.