473,385 Members | 1,326 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.

C# Windows form's Close Control Box

Hi,

How do I let the X Close Control Box incurr a Close Button when I click the
X Close Control Box?
Thanks for help.
Jason
Dec 20 '05 #1
3 6772
Hi Jason

I hope I understud your question correctly.

You need to implement the FormClosing, resp. FormClosed event.

Here an example:

private void DoMyClosingStuff()
{
// do anything you need to dispose here
}

private void CloseButton_Click(object sender, EventArgs e)
{
DoMyClosingStuff();
this.Close();
}

private void Form1_FormClosing(object sender,
FormClosingEventArgs e)
{
DoMyClosingStuff();
}

Hope this helps
Roland

Dec 20 '05 #2
Sorry Jason
I did a little mistake.

You don't need to call again the method 'DoMyClosingStuff()' in the
button click event.
By the line 'this.close' the FormClosing event will be called.

It's enough to write:

private void CloseButton_Click(object sender, EventArgs e)
{
this.Close();
}

Sorry for that missleading
Roland

Dec 20 '05 #3
Thanks Roland!
The FormClose works fine.

"Roland" <ro******************@gmx.net>
???????:11**********************@g44g2000cwa.googl egroups.com...
Hi Jason

I hope I understud your question correctly.

You need to implement the FormClosing, resp. FormClosed event.

Here an example:

private void DoMyClosingStuff()
{
// do anything you need to dispose here
}

private void CloseButton_Click(object sender, EventArgs e)
{
DoMyClosingStuff();
this.Close();
}

private void Form1_FormClosing(object sender,
FormClosingEventArgs e)
{
DoMyClosingStuff();
}

Hope this helps
Roland

Dec 21 '05 #4

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

Similar topics

7
by: Evan Kontos | last post by:
I am using the window.open function to open a small window and I am using GET to get values back from that window. I want to be able to open another from the second window but I get an error...
1
by: Codemonkey | last post by:
Hi, Sorry for the cross group post, but I couldn't find a group that deals with threading in .net. Anyway, I've noticed a difference in the way my program acts on Windows 98 than it does on...
5
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
6
by: Ayende Rahien | last post by:
Excetremely annoying problem, I've an application with a long startup time. So I created another form with my logo in it to as a splash screen. The splash screen is run from another thread and is...
5
by: Dave | last post by:
How do I check in a Windows Forms app if any controls have changed? I have a form that collects data, and I want to prompt the user if they try to exit the app, or load a new file, without saving...
3
by: Brian Keating EI9FXB | last post by:
Hello again, I've already placed a few posts on this topic. This time i've a simple application that exhibits my problem, I've placed sample solution 8k on my website should anyone be interested...
3
by: Dan | last post by:
i really need to create a window/dialog that just contains a bitmap and nothing else - no window frame, caption or buttons, or any sign of a grey background. so far ive only managed to get rid of...
1
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. I'm having trouble getting the code that I've written to work, can anyone shed some light as to where I'm...
0
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. The program I'm trying to develop needs to be able to do the following: - Select remote server -...
4
by: Rod Gill | last post by:
Hi, I have a form that when opened in the designer appears of the screen. The form selector can't be dragged (or resized) and if I scroll right and down to centralise it the form simply jumps...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.