1、MessageBox.Show("hello","world!",MessageBoxButtons.OKCancel,MessageBoxIcon.Error); 我想在按了 “是”之后 做一些工作,怎么知道我按的是 “是 ”还是“取消”怎么写代码?if (MessageBox.Show("hello", "world!", MessageBoxButtons.OKCancel, MessageBoxIcon.Error) == DialogResult.OK) { //你要做的事情 } else { }//取消同理 DialogResult.Cancel
在消息框的括号内中给参数也可以,要详细,回答正确者,我给高分!请各位大师解答!!!!!
我是说消息框中的设的确定按钮(MessageBoxButtons.OK)居中
,不是消息框,听清楚没有?
MessageBox的位置没方法控制,它会自动在屏幕中间显示, 你可以设置主窗体的位置屏幕居中:this.StartPosition = FormStartPosition.CenterScreen; 当然,你也可以自己定义个对话框窗体。 MessageBox.Show("要显示的文本内容","标题中的文本",MessageBoxButtons.OK,MessageBoxIcon.Information);//后面两个参数分别是 按钮类型和图标类型。3、 http://www.cnblogs.com/music-liang/archive/2011/09/14/2176021.html
下面是详细的代码 。
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;
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
{
MessageBox.Show(" 1 个参数 "
);
}
{
MessageBox.Show(" 2 个参数。。 ",
"亮仔提示"
);
}
{
MessageBox.Show(" 3 个参数。。。 ",
" 亮仔提示",
MessageBoxButtons.YesNoCancel
);
}
private void button4_Click(object sender, EventArgs e)
{
MessageBox.Show(" 4 个参数。。。 ",
" 亮仔提示",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Warning
);
}
{
MessageBox.Show(" 5 个参数。。 。 ",
" 亮仔提示",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button2,
);
}
{
MessageBox.Show(" 6 个参数。。。 ",
" 亮仔提示",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button2,
MessageBoxOptions.RtlReading //ServiceNotification//.RightAlign // 标题向右对齐。
);
private void button7_Click(object sender, EventArgs e)
{
MessageBox.Show(" 7 个参数。。帮助菜单不可用。。。。。 ",
" 亮仔提示",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button2,
MessageBoxOptions.RightAlign,
true // 标题向右对齐。。。。。
);
{
MessageBox.Show(" 7 个参数。帮助菜单 可用。 ",
" 亮仔提示",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button2,
MessageBoxOptions.RightAlign , // 要使用默认风格,此处参数可设为 0
@"C:\Documents and Settings\Administrator\桌面\新建文本文档.txt"
);
}
}
}