TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Song Lee
NA
47
38.6k
Winform Alt F4 exit YesNo dialog
Nov 6 2014 7:18 PM
Hello, I want to add in a feature.
When exit button is clicked, it'll give Yes or No option.
If Yes, application closes, if No, nothing happens.
I have no problem with the coding below when it comes to "Click",
but when I press "Alt F4", program closes even if I click "No"
private void
exitButton_Click(
object
sender,
EventArgs
e)
{
while
(
MessageBox
.Show(
"Exit app?","Exit message"
,
MessageBoxButtons
.YesNo) ==
DialogResult.
Yes)
{
this
.Close();
}
//If "No", MessageBox closes
}
//////////////////////////////////////////////////////////////////////////////////
private void
MainForm_KeyDown(
object
sender,
KeyEventArgs
e)
{
if
(e.Alt && e.KeyCode ==
Keys
.F4)
{
exitButton_Click(
null, null
);
}
|
Reply
Answers (
2
)
pass textbox value to model via controller windows form,mvc
TCPIP Listener