simple: Keep ShowDialog Form from closing on AcceptButton

  • Thread starter Thread starter Wardeaux
  • Start date Start date
W

Wardeaux

All,
I have login form used with ShowDialog(). I have the AcceptButton
property set so that the "Enter" key is mapped. I also need to keep the
dialog open when the UserID and PWD are invalid so user can reenter them.
How to I prevent the form from closing?

MTIA
wardeaux
 
* "Wardeaux said:
I have login form used with ShowDialog(). I have the AcceptButton
property set so that the "Enter" key is mapped. I also need to keep the
dialog open when the UserID and PWD are invalid so user can reenter them.
How to I prevent the form from closing?

Set the button's 'DialogResult' property to 'None', then add something
like the code below to the button's 'Click' event handler:

\\\
If IsValidPassword(...) Then
Me.DialogResult = DialogResult.OK
Me.Close()
Else
...
End If
///
 
Herfried,
many thanks!
wardeaux

Herfried K. Wagner said:
Set the button's 'DialogResult' property to 'None', then add something
like the code below to the button's 'Click' event handler:

\\\
If IsValidPassword(...) Then
Me.DialogResult = DialogResult.OK
Me.Close()
Else
...
End If
///
 
Back
Top