自定义消息框(对话框)Windows窗体C#

自定义消息框(对话框)Windows窗体C#,c#,winforms,dialog,messagebox,showdialog,C#,Winforms,Dialog,Messagebox,Showdialog,为了尝试使用对话框而不是MessageBox,我使用了以下代码: static public DialogResult ShowDialog(string title, string largeHeading, string smallExplanation, string leftButton, string rightButton, Image iconSet) { using (BetterDialog dialog = new Be

为了尝试使用对话框而不是MessageBox,我使用了以下代码:

        static public DialogResult ShowDialog(string title, string largeHeading, string smallExplanation,
        string leftButton, string rightButton, Image iconSet)
    {
        using (BetterDialog dialog = new BetterDialog(title, largeHeading, smallExplanation, leftButton,
            rightButton, iconSet))
        {
            DialogResult result = dialog.ShowDialog();
            return result;
        }
    }
有关更多详细信息,请参阅此代码

然后,我使用按钮单击事件调用对话框,如下所示:

        private void btnDialog_Click(object sender, EventArgs e)
    {
        BetterDialog dialogBox = new BetterDialog("Special Dialog", "large heading", "small explanation", null, "Ok", null);
        dialogBox.ShowDialog(this);
    }
我得到了一个错误:

“DotNetPerls.BetterDialog”不包含接受6个参数的构造函数


出了什么问题,有什么想法吗?

我猜接受6个参数的
BetterDialog
构造函数是私有的(或受保护的),而不是公共的

这意味着使用它的接口不是由构造函数,而是通过静态方法:

private void btnDialog_Click(object sender, EventArgs e)
{
    DialogResult result = BetterDialog.ShowDialog("Special Dialog", "large heading", "small explanation", null, "Ok", null);
    if (result == DialogResult.OK)
    {
       // Do what you want to do when OK button is pressed
    }
}

在表单中添加图片框并使用
Image.FromFile()

您的答案是正确的,非常感谢。我想问另一个小问题:如何从目录中指定要在对话框中显示的图像?@eyossi,您看到我的最后一个问题了吗?