Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 1st, 2004, 05:15 AM
Authorized User
 
Join Date: Mar 2004
Location: , , .
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default closing Form

hello
i have a closing method taht occurs whenever i close the form(X-on the top right side) :

this.Closing += new System.ComponentModel.CancelEventHandler(this.Form _Closing);

and i have a "Cancel" button that suppose to do exectly the same operation:

this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);


how can i operate the 'this.Form_Closing' function also when i click the "Cancel" button without copy all my operations in 'this.Form_Closing' function or opposite, how can i operate the 'this.buttonCancel_Click' function when i press the X.

thanks
koby

Reply With Quote
  #2 (permalink)  
Old June 1st, 2004, 08:30 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

So simple dear just close ur window in ur buttonCancel_Click function like
Code:
this.Close();
Always:),
Hovik Melkomian.
Reply With Quote
  #3 (permalink)  
Old June 17th, 2004, 04:47 PM
tnd tnd is offline
Authorized User
 
Join Date: Jun 2004
Location: , , .
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Simply call the other function from the first function
ie
Form_closing()
{
..your codes..
buttonCancel_Click;
}
Do the same for buttonCancel_Click. But one problem is since the 2 functions calls each other, you have an endless loop here. So you need to code some control variables to terminate correctly.



Reply With Quote
  #4 (permalink)  
Old June 19th, 2004, 03:28 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

dear tnd:
what peoblem u have found there?! I see no problem!

Always:),
Hovik Melkomian.
Reply With Quote
  #5 (permalink)  
Old July 1st, 2004, 03:34 PM
Authorized User
 
Join Date: Jul 2004
Location: , , .
Posts: 69
Thanks: 0
Thanked 1 Time in 1 Post
Default

this.Close();

That should work... you are right.


www.CoderForRent.com
Get A Computer Job!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
closing a form mnvijay VS.NET 2002/2003 4 December 18th, 2007 07:20 AM
Form closing bschleusner C# 2005 2 February 4th, 2007 04:07 PM
How to refresh owner form on closing of child form akumarp2p C# 2005 0 December 22nd, 2006 10:27 AM
Closing a form after opening another form rosebushr Access 2 January 7th, 2006 04:34 AM
Save Records Before Closing Form Ben Horne Access VBA 1 March 30th, 2004 11:47 PM



All times are GMT -4. The time now is 12:09 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.