Question

In order to try to use a dialog box instead of MessageBox I used the next code:

        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;
        }
    }

for more details, this code is found here

Then I used a button click event to call the dialog box as follows:

        private void btnDialog_Click(object sender, EventArgs e)
    {
        BetterDialog dialogBox = new BetterDialog("Special Dialog", "large heading", "small explanation", null, "Ok", null);
        dialogBox.ShowDialog(this);
    }

I got the Error:

'DotNetPerls.BetterDialog' does not contain a constructor that takes 6 arguments.

What's wrong, Any idea please ?

Was it helpful?

Solution

I guess that the BetterDialog constructor that takes 6 arguments is private (or protected) and not public...

that means that the interface to use it is not by the constructor, but through the static methods only:

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
    }
}

OTHER TIPS

Add a picture box to your Form and use Image.FromFile().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top