473,385 Members | 1,927 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to assign/call a function when a "Close" button of a Form is cliecked?

Assume I have an open Form.

Then I click the "normal" window "X" icon (=Close button). How do I assign a function in Form.cs
to this event ? In other words if this Form/window is closed I want to perform some exit statements.

When I doubleclick on a "normal" button I am autoamtically taken from the designer pane
into the source code editor pane and a new function is automatically inserted.

This is not the case for a system button like the "close" window button.

Carla

May 24 '07 #1
2 2281
Carla,

In order to do this, you want to attach an event handler to the Closed
event of the form. In order to do this in the designer, select the form
(not a control on the form) and look in the properties window. Click on the
thunderbolt, and you will see a list of events for the form. Double click
on the "Closed" one and the designer will create an event handler for you if
it doesn't already exist, or take you to the existing one if it does.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Carla Simeoni" <c.****@subnet.netwrote in message
news:46**********************@newsspool2.arcor-online.net...
Assume I have an open Form.

Then I click the "normal" window "X" icon (=Close button). How do I assign
a function in Form.cs
to this event ? In other words if this Form/window is closed I want to
perform some exit statements.

When I doubleclick on a "normal" button I am autoamtically taken from the
designer pane
into the source code editor pane and a new function is automatically
inserted.

This is not the case for a system button like the "close" window button.

Carla

May 24 '07 #2
On Thu, 24 May 2007 10:14:05 -0700, Carla Simeoni <c.****@subnet.net
wrote:
Assume I have an open Form.

Then I click the "normal" window "X" icon (=Close button). How do I
assign a function in Form.cs
to this event ? In other words if this Form/window is closed I want to
perform some exit statements.
Find the "Closing" event in the event list for the form's properties, and
assign your method there. If you want the designer to create a new method
stub for you, double-click in the empty box next to the event.

There are *lots* of events you can assign this way. Double-clicking on a
control itself only ever gets you the single default event for the
designer. The rest of the events, you have to attach from the properties
list (or write the code manually, of course).

Pete
May 24 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Reggie | last post by:
Hi and TIA! I have a form and have set the Close Button to false so that users must exit using my close button. However when I open a Report from this form I want the close button to be available...
1
by: lauren quantrell | last post by:
Before getting pistol whipped, I know this is a well-worn topic but I don't see the answer... I know how to hide the Access window, I know how to disable the Access application's close button, but...
9
by: cor-travel | last post by:
Hi Folk Is there a way to disable the close button for an application? Thank you - Nicolaas
2
by: Tom_F | last post by:
To comp.databases.ms-access -- I would like to trigger an event when I close a form -- but ONLY when the data in the "RecordSource" table has been updated. I tried using the AfterUpdate event,...
0
by: bloombloom | last post by:
I am gonna post my AS in hopes that someone can get a good understanding of what i am doing. So here is the code: t1.onRelease = function() { infoField._visible = true; startLoading("cc11.swf");...
3
by: mfleet1973 | last post by:
Hi. Visual Studio 2003. Is there a way to disable another application's form's close button that is on the taskbar? Cheers. Mike.
1
by: sreedhardasi | last post by:
Hi, I would like to call a javascript function when user clicks on browser's close button. Here is the scenario. 1. User clicks browser close button. 2. User will be displayed a popup or a...
5
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.