Search code examples
c#winformsdialogshowdialog

How to customized icon image on a dialog box


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

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)
    {
    // Action to perform ...
    }
    }

how can I specify the icon image from a given folder to show on the dialogbox ?


Solution

  • try:

    private void btnDialog_Click(object sender, EventArgs e)
    {
       DialogResult result = BetterDialog.ShowDialog("Special Dialog", "large heading", "small explanation", null, "Ok", Image.FromFile(@"fullPath\FileName.ext"));
       if (result == DialogResult.OK)
       {
       // Action to perform ...
       }
    }
    

    But it will change the image inside the dialog box, (if you want to change the icon of the dialog caption - i think it is not possible without modifying BetterDialog code)