0

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 ?

Sami-L
  • 5,553
  • 18
  • 59
  • 87

2 Answers2

2

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
    }
}
eyossi
  • 4,230
  • 22
  • 20
  • Your answer is right, many thanks. I would ask another small question please: how to specify an image to show in the dialog from a directory ? – Sami-L Jul 16 '12 at 22:53
  • @ eyossi, have you seen my last question please ? – Sami-L Jul 16 '12 at 22:59
0

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

DaveShaw
  • 52,123
  • 16
  • 112
  • 141
Adi Peer
  • 41
  • 1
  • 8