在C# WinForm中添加退出前确认功能,就要自行添加FormClosing事件。方法如下:[喝小酒的网摘]http://blog.hehehehehe.cn/a/17725.htm
 
在frmMain.Designer.cs中的InitializeComponent()添加:
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmMain_FormClosing);
 
在frmMain.cs中添加:

private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
{
    if (MessageBox.Show("你确定要退出?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
        e.Cancel = false;
    else
        e.Cancel = true;
}

也可以在IDE中,在Form的事件中添加事件,系统会自动添加上部分代码。


this.button3.Image = Properties.Resources.tab_scan;
            Bitmap bmp = (Bitmap)Properties.Resources.tab_update;
            //this.button3.Image = Bitmap.FromFile("d:\tmp.bmp");
            this.button3.Image = bmp.Clone(new System.Drawing.Rectangle(172*2, 0, 172, 38), button3.Image.PixelFormat);