close button event for form

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2009
Posts: 22
Reputation: bk_bhupendra is an unknown quantity at this point 
Solved Threads: 1
bk_bhupendra bk_bhupendra is offline Offline
Newbie Poster

close button event for form

 
0
  #1
29 Days Ago
how can i control the close button in a form....
(the three bottons minimize,maxi,close for all windows form)
i hav attached a fig... jst check it...
n pls reply
Attached Thumbnails
untitled.JPG  
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 916
Reputation: DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough 
Solved Threads: 147
DdoubleD DdoubleD is offline Offline
Posting Shark
 
2
  #2
29 Days Ago
You can handle the close event on the form using the following event handler:

  1. private void Form1_FormClosing(object sender, FormClosingEventArgs e)
  2. {
  3. if (DialogResult.No == MessageBox.Show("Exit without saving changes?", "Data Not Saved", MessageBoxButtons.YesNo))
  4. e.Cancel = true;
  5. }

The above event will be called whenever the Close() method is executed. Use e.Cancel = true to stop the form from being closed.
Last edited by DdoubleD; 29 Days Ago at 10:37 am.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 22
Reputation: bk_bhupendra is an unknown quantity at this point 
Solved Threads: 1
bk_bhupendra bk_bhupendra is offline Offline
Newbie Poster

sry its nt wrking....

 
0
  #3
28 Days Ago
Hey its not working...
sud i doudl click smthing jst lik in case of bottons
doubleclicking on that "red cross" results in page load...
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 359
Reputation: Ryshad has a spectacular aura about Ryshad has a spectacular aura about 
Solved Threads: 65
Ryshad's Avatar
Ryshad Ryshad is offline Offline
Posting Whiz
 
0
  #4
28 Days Ago
Double clicking on a control will create the default event handler. To create handles for other events, got to the properties panel and change to the Events section (lightning bolt at top).
Then double click on the area next to the required event and a basic event handler will be created for you.

Check out the image to see where you ened to click.

Remember to mark the thread as solved if this answered your question.
Attached Thumbnails
eventhandle.png  
Please don't take for granted the work that solvers do for you. Take the time to fully understand the code they give you so that you might adapt it to future problems.

"Learning is more than absorbing facts, it is acquiring understanding.” - William Arthur Ward
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 916
Reputation: DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough 
Solved Threads: 147
DdoubleD DdoubleD is offline Offline
Posting Shark
 
1
  #5
27 Days Ago
You can also add the event handler directly in your form's constructor in the form of:

  1. public Form1()
  2. {
  3. InitializeComponent();
  4. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
  5. }
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 328
Reputation: Diamonddrake is a jewel in the rough Diamonddrake is a jewel in the rough Diamonddrake is a jewel in the rough 
Solved Threads: 39
Diamonddrake's Avatar
Diamonddrake Diamonddrake is offline Offline
Posting Whiz
 
0
  #6
26 Days Ago
If you need to customize all 3 of the buttons events, the standard practice is to create a your own title bar control such as seen on AIM and Y! instant messengers.

otherwise, DDoubleD has the right idea.
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC