/*
*程序的版权和版本声明部分:
*程序的版权和版本声明部分:
*Copyright(c)2013,烟台大学计算机学院学生
*All rights reserved.
*文件名称:
*作者:尚振伟
*完成日期:2014年11月11日
*版本号:v0.1
*对任务及求解方法的描述部分:
*输入描述:无
*问题描述:在窗体上增加一个按钮,并设置按钮显示文字为“结束程序”。单击该按钮显示如下消息框,若选择是,则结束程序,否则只是关闭消息框。
*程序输入:
*程序输出:
*问题分析:
*算法设计:
*我的程序:
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show("确定要结束程序吗?[Yes|No]", "提示",
MessageBoxButtons.YesNo,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button2);
if(result==DialogResult.Yes)
{
Application.Exit();
}
}
}
}
结果展示:
心得体会:晚上做梦又去上大一了,还好是个梦。