![]() |
| | #1 |
| Registered User Join Date: Jun 2009
Posts: 21
| Editing the Red X Control Button.... I've stuck some simple code in my form cancel / ok buttons that disables any predecesing forms, and then enables them and brings them to the front once they are required again. Is there any way to replicate this code in the Red X control button? I don't want to remove the whole controlbox as I'd like to keep minimise / maximise functionality. Thanks. |
| scott_ill is offline | |
| | #2 |
| Registered User Join Date: Mar 2009 Location: england
Posts: 76
| If I understand you correctly, you want the X button to do something and then not close the application? You need to use the OnFormClosing event, which you can place anywhere in your form class: Code: protected override void OnFormClosing(FormClosingEventArgs e)
{
// put your custom code here
e.Cancel = true; // prevent form closure
base.OnFormClosing(e);
}
Code: protected override void OnFormClosing(FormClosingEventArgs e)
{
DialogResult result = MessageBox.Show("Are you sure you want to quit?", "Exit?", MessageBoxButtons.OKCancel);
if (result != DialogResult.OK)
e.Cancel = true;
else
base.OnFormClosing(e);
}
|
| theoobe is offline | |
| | #3 |
| Registered User Join Date: Jun 2009
Posts: 21
| Great stuff. Thanks. |
| scott_ill is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Button and edit control border | maxorator | Windows Programming | 4 | 11-04-2005 02:31 PM |
| Binary Search Trees Part III | Prelude | A Brief History of Cprogramming.com | 16 | 10-02-2004 03:00 PM |
| BN_CLICKED, change button style | bennyandthejets | Windows Programming | 9 | 09-11-2002 03:59 AM |
| I need some ideas please>> | Unregistered | C Programming | 3 | 08-23-2002 01:55 PM |
| Tab Controls - API | -KEN- | Windows Programming | 7 | 06-02-2002 09:44 AM |