P
Paolo Pagano
I have a Form with two TextBox's, I validate first one:
private void textBox1_Validating( object sender, CancelEventArgs e )
{
if( String.IsNullOrEmpty( textBox1.Text ) )
{
DialogResult res = MessageBox.Show( "Retry?", "Error: empty
value",
MessageBoxButtons.RetryCancel
);
e.Cancel = ( res == DialogResult.Retry );
}
}
Pressing "Retry" button, we can correct the value; the problem is that
second TextBox
reives Focus after validation method! (raising unwanted application logic);
This seems due to "MessageBox.Show" (setting 'e.Cancel = true' without
MessageBox.Show
works correctly)
Why this? Am I missing something?
Thank you.
private void textBox1_Validating( object sender, CancelEventArgs e )
{
if( String.IsNullOrEmpty( textBox1.Text ) )
{
DialogResult res = MessageBox.Show( "Retry?", "Error: empty
value",
MessageBoxButtons.RetryCancel
);
e.Cancel = ( res == DialogResult.Retry );
}
}
Pressing "Retry" button, we can correct the value; the problem is that
second TextBox
reives Focus after validation method! (raising unwanted application logic);
This seems due to "MessageBox.Show" (setting 'e.Cancel = true' without
MessageBox.Show
works correctly)
Why this? Am I missing something?
Thank you.