C# Tutorial 19: Message Box Asking if The User Wants To Exit

  Рет қаралды 153,731

ProgrammingKnowledge

ProgrammingKnowledge

Күн бұрын

ClickOnce creates defect runtime code‎ C sharp
★★★Top Online Courses From ProgrammingKnowledge ★★★
Python Programming Course ➡️ bit.ly/2vsuMaS ⚫️ bit.ly/2GOaeQB
Java Programming Course ➡️ bit.ly/2GEfQMf ⚫️ bit.ly/2Vvjy4a
Bash Shell Scripting Course ➡️ bit.ly/2DBVF0C ⚫️ bit.ly/2UM06vF
Linux Command Line Tutorials ➡️ bit.ly/2IXuil0 ⚫️ bit.ly/2IXukt8
C Programming Course ➡️ bit.ly/2GQCiD1 ⚫️ bit.ly/2ZGN6ej
C++ Programming Course ➡️ bit.ly/2V4oEVJ ⚫️ bit.ly/2XMvqMs
PHP Programming Course ➡️ bit.ly/2XP71WH ⚫️ bit.ly/2vs3od6
Android Development Course ➡️ bit.ly/2UHih5H ⚫️ bit.ly/2IMhVci
C# Programming Course ➡️ bit.ly/2Vr7HEl ⚫️ bit.ly/2W6RXTU
JavaFx Programming Course ➡️ bit.ly/2XMvZWA ⚫️ bit.ly/2V2CoAi
NodeJs Programming Course ➡️ bit.ly/2GPg7gA ⚫️ bit.ly/2GQYTQ2
Jenkins Course For Developers and DevOps ➡️ bit.ly/2Wd4l4W ⚫️ bit.ly/2J1B1ug
Scala Programming Tutorial Course ➡️ bit.ly/2PysyA4 ⚫️ bit.ly/2PCaVj2
Bootstrap Responsive Web Design Tutorial ➡️ bit.ly/2DFQ2yC ⚫️ bit.ly/2VoJWwH
MongoDB Tutorial Course ➡️ bit.ly/2LaCJfP ⚫️ bit.ly/2WaI7Ap
QT C++ GUI Tutorial For Beginners ➡️ bit.ly/2vwqHSZ
★★★ Online Courses to learn ★★★
Get 2 FREE Months of Unlimited Classes from skillshare - skillshare.eqc...
Data Science - bit.ly/2lD9h5L | bit.ly/2lI8wIl
Machine Learning - bit.ly/2WGGQpb | bit.ly/2GghLXX
Artificial Intelligence - bit.ly/2lYqaYx | bit.ly/2NmaPya
MERN Stack E-Degree Program - bit.ly/2kx2NFe | bit.ly/2lWj4no
DevOps E-degree - bit.ly/2k1PwUQ | bit.ly/2k8Ypfy
Data Analytics with R - bit.ly/2lBKqz8 | bit.ly/2lAjos3
AWS Certification Training - bit.ly/2kmLtTu | bit.ly/2lAkQL1
Projects in Java - bit.ly/2kzn25d | bit.ly/2lBMffs
Machine Learning With TensorFlow - bit.ly/2m1z3AF | bit.ly/2lBMhnA
Angular 8 - Complete Essential Guide - bit.ly/2lYvYRP
Kotlin Android Development Masterclass - bit.ly/2GcblsI
Learn iOS Programming Building Advance Projects - bit.ly/2kyX7ue
★★★ Follow ★★★
My Website - www.codebind.com
DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This help support the channel and allows us to continue to make videos like this. Thank you for the support!
Message Box Asking Wether The User Wants To Save Before
FormClosing and Application.Exit is causing the MessageBox to c#
MessageBox Issue Windows Forms Application C#
How can I prevent window closing by showing a MessageBox ? Show( "Do you really want to close? Do you want to save before exiting? Visual C#
Show("Do you really want to close the program?", "SomeTitle", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { Application.Exit()

Пікірлер: 87
@jepkenept6746
@jepkenept6746 9 жыл бұрын
Instead of writing application.exit(); use e.cancel=false; you wont need to double click yes! hope this helps
@imPymo
@imPymo 9 жыл бұрын
Jep Kenept Thanks. :D
@jepkenept6746
@jepkenept6746 9 жыл бұрын
Jonathan No problem, glad that i could help.
@markpace123
@markpace123 9 жыл бұрын
Jep Kenept Works :D thank you!
@chintangotecha7089
@chintangotecha7089 9 жыл бұрын
Jep Kenept It works well, thanks a ton
@jepkenept6746
@jepkenept6746 9 жыл бұрын
Mark Pace :) your welcome. Happy Coding.
@whyisthishandletaken
@whyisthishandletaken 11 жыл бұрын
Thank you. ProgrammingKnowledge should take your response as it sorts out the program
@GIDEONKIMATHI
@GIDEONKIMATHI 11 жыл бұрын
Application.ExitThread() works fine.
@Makeforfun18799
@Makeforfun18799 6 жыл бұрын
clear and easy to understand me.thanks
@cyberpunk_42
@cyberpunk_42 9 жыл бұрын
just get rid of the first IF for the YES option :) ...if you then save it and click on yes it closes the application anyways, and the NO option works as intended... hope it helps its the easiest way...
@jjstairs
@jjstairs 6 жыл бұрын
If you want to fix your code so the message only shows once replace "Application.Exit();" with "this.Dispose();". It fixed the issue in my program.
@theCEO-e9f
@theCEO-e9f 8 жыл бұрын
instead of using Application.Exit(); you can also use there e.Cancel=false;
@TripleForce
@TripleForce 10 жыл бұрын
sorry guys... I already solve the e.Cancel error and is now OK... I did mistake of putting the code in the different procedures... my bad... thanks ProgrammingKnowledge for this code....
@serique1323
@serique1323 10 жыл бұрын
There in your tutorial Form1 - .Hide and it is in RAM. WHen you close 2nd form - programm asks 2 times for closing - 1st time for Form2 and second time for Form1. How can i "kill" form1 and get only 1 message "Are you sure want to exit" instead of 2?
@kevinkastrowiak
@kevinkastrowiak 11 жыл бұрын
exciting ! ! thanks fella ! !
@PCGaming300
@PCGaming300 11 жыл бұрын
How do you make it so that it asks if you want to save your work before closing the program?
@soyal24
@soyal24 8 жыл бұрын
tnx bro i used it to Delete button "r u sure u want to delete"
@UMARBASHIR
@UMARBASHIR 11 жыл бұрын
Use it Application.ExitThead();
@mohamedahmedhamud4279
@mohamedahmedhamud4279 4 жыл бұрын
yes my brother thank you first i need c# tutorial 1upto last how can i get sorted tutorials thanks a lot
@sandeepscs
@sandeepscs 11 жыл бұрын
e.cancel is not available? what do do? e.CloseReason only?
@philipm1896
@philipm1896 8 жыл бұрын
processes.kill() stops everything imediately instead or .exit() which is a request or .close()
@DavidAshby1
@DavidAshby1 10 жыл бұрын
How would you make this a class so that if your application had multiple forms you could reuse the same code rather than wasting a lot of time repeating the code in each form? Thanks
@a.n.7338
@a.n.7338 7 жыл бұрын
guys i am having problem when saving my c# application it is giving error of some kind i have to make project and have to save it to later connect to mysql i don"t know what to do??
@cutipets8706
@cutipets8706 5 жыл бұрын
Application.ExitThead(); works fine.
@magnumsars
@magnumsars 8 жыл бұрын
Its asks 2 times when i click yes. why is that ? can you help me ?
@Junaidlahori
@Junaidlahori 11 жыл бұрын
jst remove if for the application exit and use the cancel codes.which shown in video and its done.
@slodkigrejpfrut
@slodkigrejpfrut 10 жыл бұрын
Why do you upload the video with code that doesn't work as it should? You should wrote in the comment that this solution doesn't work well....:/
@buengi-wn3nt
@buengi-wn3nt 6 жыл бұрын
private void Form_Main_FormClosing(object sender, FormClosingEventArgs e) { DialogResult result = MessageBox.Show("EXIT?", "Exit Program", MessageBoxButtons.YesNo); if (result != DialogResult.Yes) { e.Cancel = true; } }
@lifestyle_
@lifestyle_ 9 жыл бұрын
e.cancel is not working ... please could you help me???
@xchgamer
@xchgamer 7 жыл бұрын
Just copy this: DialogResult dialog = MessageBox.Show("Do you really want to close this application?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if(dialog == DialogResult.Yes) { Application.ExitThread(); } else { e.Cancel = true; }
@nghiatran5834
@nghiatran5834 6 жыл бұрын
thank you for your clip
@WennieBoy01
@WennieBoy01 11 жыл бұрын
yeah it really help
@TripleForce
@TripleForce 10 жыл бұрын
anyone can help me.. this application.exit(); work fine but e.Cancel is not...error - it says "does not contain definition"
@This1Guy1979
@This1Guy1979 9 жыл бұрын
Rodoon Pocson Be sure to double click on form closing, not form closed from the event list.
@xchgamer
@xchgamer 7 жыл бұрын
So you have the "FormClosingEventArgs e" in arguments?
@FleynSoft
@FleynSoft 7 жыл бұрын
thank you =)
@synapsefn3283
@synapsefn3283 8 жыл бұрын
"dialog" is an error :/
@kingluther2365
@kingluther2365 11 жыл бұрын
The Problem is this code (dialog == DialogResult.Yes) Try this (dialog != DialogResult.Yes)
@junreyongcol
@junreyongcol 10 жыл бұрын
yes this seems the better idea. salamat tol
@iProCombo
@iProCombo 7 жыл бұрын
Watch 1.5x speed
@shoaibmehmood7339
@shoaibmehmood7339 6 жыл бұрын
Use this method : Application.ExitThread();
@dbs03075
@dbs03075 3 жыл бұрын
I love you
@jansmcwyn2870
@jansmcwyn2870 9 жыл бұрын
my visual studio is 2010 but the e.cancel not works..
@TheElectricCherry
@TheElectricCherry 8 жыл бұрын
Jans Mcwyn Cunanan mine is 2015 (I think) and it still doesn't work
@higsonS2
@higsonS2 11 жыл бұрын
It work
@malohtie
@malohtie 9 жыл бұрын
dont need tu use application.exit();
@TheElectricCherry
@TheElectricCherry 8 жыл бұрын
e.Cancel = true; isn't real
@ahmedsalah2662
@ahmedsalah2662 10 жыл бұрын
Application.ExitThread() works fine.
@hardip5523
@hardip5523 10 жыл бұрын
This works great, and it's only a few extra characters compared to a whole different method! Thank you for sharing!
@abodesegunezekiel6145
@abodesegunezekiel6145 10 жыл бұрын
Thanks Mr Ahmed i cannot but testify that it Works
Message Box Asking if The User Wants To Exit in C#
4:07
BTech Days
Рет қаралды 838
Coding a Web Server in 25 Lines - Computerphile
17:49
Computerphile
Рет қаралды 362 М.
Сестра обхитрила!
00:17
Victoria Portfolio
Рет қаралды 958 М.
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19
C# Tutorial 1:Getting Started and Mysql database Connection
17:49
ProgrammingKnowledge
Рет қаралды 583 М.
How to Master the VBA Message Box in 6 Minutes
5:52
Excel Macro Mastery
Рет қаралды 50 М.
C# Tutorial 22: Checkbox , radiobutton and groupbox with Database in C#
14:34
ProgrammingKnowledge
Рет қаралды 244 М.
How to Program in C# - BASICS (E01)
11:48
Brackeys
Рет қаралды 1,5 МЛН
C# Tutorial 55:   Passing a value from one form to another form in C#
11:50
ProgrammingKnowledge
Рет қаралды 197 М.
How the C++ Linker Works
15:52
The Cherno
Рет қаралды 656 М.
Tutorial : How to Create a Toast Message. C# | Windows Form
12:42
Coding Ideas
Рет қаралды 13 М.
The Rust Survival Guide
12:34
Let's Get Rusty
Рет қаралды 181 М.