- 14
- 0
- 约6.88千字
- 约 7页
- 2017-05-27 发布于河南
- 举报
MessageBox用法小结
下面的代码示例演示如何询问用户一个是与否的问题,并根据响应做出决定。
Example
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text )
{
string message = 未进行任何输入,是否取消?;
string caption = 输入错误;
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
DialogResult result;
result = MessageBox.Show(message, caption, buttons);
if (result System.Windows.Forms.DialogResult.Yes)
{
this.Close();
}
else
{
textBox1.Focus();
}
}
else
{
MessageBox.Show(你输入的内容为 + textBox1.Text);
}
原创力文档

文档评论(0)