By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,239 Members | 1,493 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,239 IT Pros & Developers. It's quick & easy.

simple: Keep ShowDialog Form from closing on AcceptButton

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
* "Wardeaux" <wa******@bellsouth.net> scripsit:
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
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2

P: n/a
Herfried,
many thanks!
wardeaux

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eK**************@TK2MSFTNGP10.phx.gbl...
* "Wardeaux" <wa******@bellsouth.net> scripsit:
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
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.