simple: Keep ShowDialog Form from closing on AcceptButton

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
 
H

Herfried K. Wagner [MVP]

* "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
///
 
W

Wardeaux

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
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top