Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

C# Application Form Closing Event Question

Posted on March 23, 2014October 26, 2015 By David Kittell

Sometimes you have a program that you would prefer someone not close without confirming they truly meant to close it.

This script will assist in providing a question before the program simply closes.

private void fm1_FormClosing(object sender, FormClosingEventArgs e)
		{
			DialogResult dialogResult = MessageBox.Show("Are you sure you want to close?", Application.ProductName, MessageBoxButtons.YesNo);
			if (dialogResult == DialogResult.Yes)
			{
				// Truly Close
				e.Cancel = false;
			}
			else if (dialogResult == DialogResult.No)
			{
				// Oops Don't close
				e.Cancel = true;
			}
		}
Originally Posted on March 23, 2014
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code CSharp

Post navigation

Previous post
Next post

Related Posts

Ektron – Stop / Start Services

Posted on March 5, 2014October 26, 2015

This should only be done on a development computer, doing so on a production server would not be good. Please note that while stopping the services I’m also setting the start command to “demand” this is also known as “manual”. In setting this command Ektron will no longer automatically start…

Read More

Remove HTML Tags

Posted on October 23, 2013October 26, 2015

This script will remove all HTML tags from a given column in a table, useful if you need to simply have the text. IF OBJECT_ID(N’dbo.RemoveHTMLTags’) IS NOT NULL DROP FUNCTION dbo.RemoveHTMLTags GO CREATE FUNCTION [dbo].[RemoveHTMLTags] (@HTMLText VARCHAR(MAX)) RETURNS VARCHAR(MAX) AS BEGIN DECLARE @Start INT DECLARE @End INT DECLARE @Length INT…

Read More

Trim Function

Posted on August 8, 2013October 26, 2015

–FOR SQL SERVER 2000: CREATE FUNCTION dbo.TRIM(@string VARCHAR(8000)) RETURNS VARCHAR(8000) BEGIN RETURN LTRIM(RTRIM(@string)) END GO –FOR SQL SERVER 2005: CREATE FUNCTION dbo.TRIM(@string VARCHAR(MAX)) RETURNS VARCHAR(MAX) BEGIN RETURN LTRIM(RTRIM(@string)) END GO Source: http://blog.sqlauthority.com/2007/04/24/sql-server-trim-function-udf-trim/ Originally Posted on August 8, 2013Last Updated on October 26, 2015 All information on this site is shared…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes