Custom button captions in .NET messagebox?

2019-01-11 13:37发布

Is there an easy way to display a messagebox in VB.NET with custom button captions? I came across What is an easy way to create a MessageBox with custom button text in Managed C++?, in the Stack Overflow archives, but it's for Managed C++.

8条回答
混吃等死
2楼-- · 2019-01-11 13:54

Add this to the button that you want the dialog to be shown from. This is a custom form messageBox;

    private void DGroup_Click(object sender, EventArgs e)
    {
        messageBox m = new messageBox();
        m.ShowDialog();
        if (m.DialogResult == DialogResult.Yes)
        {
            //del(groups.php?opt=del&id=613','asdasd');
            String[] asd = new String[2];
            asd[0] = "groups.php?opt=del&id=613";
            asd[1] = "asdasd";
            addgroup.Document.InvokeScript("del",asd);
        }
        else
            if (m.DialogResult == DialogResult.No)
            {
                MessageBox.Show("App won´t close");
            }
    }

Add this code to messageBox.

    private void deleteGroupOnly_Click(object sender, EventArgs e)
    {
        this.DialogResult = DialogResult.Yes;
        this.Close();
    }

    private void deleteAll_Click(object sender, EventArgs e)
    {
        this.DialogResult = DialogResult.No;
        this.Close();
    }

    private void cancel_Click(object sender, EventArgs e)
    {
        this.DialogResult = DialogResult.Cancel;
        this.Close();
    }
查看更多
Root(大扎)
3楼-- · 2019-01-11 13:59

C# code to accomplish the same thing can be found in an article under MSDN forum, https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3087899&SiteID=1.

查看更多
登录 后发表回答