473,394 Members | 1,866 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,394 software developers and data experts.

CloseButton

Hi Everybody,

How do I display a message when CloseButton on the form is clicked??
Nov 3 '09 #1
2 2030
tlhintoq
3,525 Expert 2GB
There is an event of .FormClosing.
Attach your method to that.
  • Open the form in Designer.
  • On the Properties pallet click the events button (yellow lightening bolt)
  • Scroll down to FormClosing
  • Double-Click in the field to the right. A method stub will be created for you and an event handler will be created.
  • Put your message in that method

Expand|Select|Wrap|Line Numbers
  1.         private void Form1_FormClosing(object sender, FormClosingEventArgs e)
  2.         {
  3.             System.Windows.Forms.DialogResult result = MessageBox.Show("Are you sure", "Close?", MessageBoxButtons.YesNo,
  4.                                                                        MessageBoxIcon.Question);
  5.             if (result == System.Windows.Forms.DialogResult.No) e.Cancel = true; // Cancel the close
  6.         }
  7.  
Nov 3 '09 #2
tlhintoq

Thanks my friend it works
Nov 4 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

53
by: Bill | last post by:
Hello Programmers, I am looking for either Java Script (OR HTML etc) to DEFEAT Pop-up Stoppers e.g It will bring up a window that will LOOK like a Pop-up FEEL like a Pop-up Allow a name and...
1
by: Peter J. Bismuti | last post by:
How do you access attributes of a class when inheriting from it? Can't you just say: self.attribute? Help?!...
2
by: equalium | last post by:
Hello I am creating div elements on the fly with javascript: .... this.closeButton = document.createElement('div'); this.closeButton.setAttribute('id', this.name+ 'Close');...
4
by: lenin42001 | last post by:
Please can you help. We've set defaults to a class employee & added data for each of the input form values 'age', 'dob', 'street' etc now we are asked to print void display for the values we have ...
4
by: lenin42001 | last post by:
public void actionPerformed (ActionEvent e) { MenuItem choice = (MenuItem)e.getSource(); if (choice == Display) display(); Please can someone help we've tried tons of...
1
by: santanu1600 | last post by:
Hi everyone, I am santanu and i am creating a project in VB6. I want to manipulate the system CloseButton appears on top right of a VB form. I want ,some work should be carried...
2
by: erag | last post by:
Hi im newbie to java, and i want to set the language change according to main page..how to create it? here is my coding: main page: import org.eclipse.swt.SWT; import...
1
kaarthikeyapreyan
by: kaarthikeyapreyan | last post by:
Beginners Game- Tic-Tac-Toe My first attempt after learning Tkinter from Tkinter import * import tkFont class myApp: """ Defining The Geometry of the GUI And the variables Used In the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.