如何为MessageBox设置自定义位置

Fra*_*ank 1 c# messagebox

我想在给定位置显示MessageBox.我不希望MessageBox覆盖并隐藏父窗体的一部分.有没有办法使用默认的MessageBox对象来指定自定义位置?

我在VS 2008中使用C#和.Net Framework 3.5

cla*_*oda 7

您无法更改消息框的属性.您必须创建自己的表单()并将其用作消息框.这样你就可以定义它的一切(位置,大小等)

这是我做过的一个.

public partial class NotifyForm : Form
    {
        public NotifyForm(string message, string title)
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;// Or wherever 

            lblMessage.Text = "\r\n" + message;
            this.Text =  title;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
Run Code Online (Sandbox Code Playgroud)

我将它初始化为:

NotifyForm frm = new NotifyForm("Added item: " + txtAddAcc.Text + " to Accessibility Categories list.", "Add Item!");
frm.Show();
Run Code Online (Sandbox Code Playgroud)