Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 1st, 2004, 05:15 AM
Authorized User
 
Join Date: Mar 2004
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

 
Old June 1st, 2004, 08:30 AM
Friend of Wrox
 
Join Date: Jun 2003
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.
 
Old June 17th, 2004, 04:47 PM
tnd tnd is offline
Authorized User
 
Join Date: Jun 2004
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.



 
Old June 19th, 2004, 03:28 AM
Friend of Wrox
 
Join Date: Jun 2003
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.
 
Old July 1st, 2004, 03:34 PM
Authorized User
 
Join Date: Jul 2004
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!





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





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