Skip to content

List of dialog boxes

yvlawy edited this page May 28, 2018 · 10 revisions

The classic error message box

commonDlg.ShowError("You're wrong.");

The Error dialog box

The Information message box

commonDlg.ShowInformation("Yes, you like dogs.");

The Information dialog box

The Warning message box

commonDlg.ShowWarning("Be carefull!");

The Warning dialog box

The Question message box

commonDlg.ShowQuestion("Do you like dogs?");

The Question dialog box

The Extra Large Width Information message box

string msg = "Yes, you like dogs, cats, birds, horses, worms, lions, ants, girafs, rabbits, ...";
commonDlg.ShowInformation(WHSize.WXL, msg);

The Extra Large Width Information dialog box

The Input text message box

string text;
CommonDlgResult res = commonDlg.ShowDlgInputText("Input", "Give a name:", "name", out text);
if (res != CommonDlgResult.Ok)
{...}

The Input text dialog box

The large width Input text message box

string text;
CommonDlgResult res = commonDlg.ShowDlgInputText(WHSize.WL, "Input", "Give a name:", "name", out text);
if (res != CommonDlgResult.Ok)
{ ... }

The large width Input text dialog box

The combo choice dialog box

List<DlgComboChoiceItem> listItem = new List<DlgComboChoiceItem>();
DlgComboChoiceItem selectedBeforeItem = null;

// create some object
List<string> listString = new List<string>();
listString.Add("dog");
listString.Add("cat");
listString.Add("horse");
listString.Add("duck");

foreach (string s in listString)
{
    var item = new DlgComboChoiceItem(s, s);
    listItem.Add(item);
}

DlgComboChoiceItem selected;
CommonDlgResult res = commonDlg.ShowDlgComboChoice("Choose it", listItem, selectedBeforeItem, out selected);

if (res == CommonDlgResult.Ok)
{...}

The combo choice dialog box

The list choice dialog box

List<DlgListChoiceItem> listItem = new List<DlgListChoiceItem>();
List<DlgListChoiceItem> listSelectedBeforeItem = null;

// create some object
List<string> listString = new List<string>();
listString.Add("Au revoir");
listString.Add("salut");
listString.Add("bye");
listString.Add("tchao");

foreach (string s in listString)
{
    var item = new DlgListChoiceItem(s, s);
    listItem.Add(item);
}

List<DlgListChoiceItem> listSelected;
CommonDlgResult res = commonDlg.ShowDlgListChoice("Choose it", listItem, listSelectedBeforeItem, out listSelected);
if (res == CommonDlgResult.Ok)
{...}

The list choice dialog box

The select file dialog box

(Use the Windows built-in dialog box.)

// * is the current folder, where is executed the application
string folderStart="*";
string defaultExt="*.*";
// text displayed|filter extension
string filter="All | *.*";

res = commonDlg.ShowDlgSelectFile(folderStart, defaultExt, filter, out pathName, out fileName);
if (res == CommonDlgResult.Ok)
{ ... }

see: https://www.c-sharpcorner.com/uploadfile/mahesh/openfiledialog-in-C-Sharp/ to have more details.

Put two filters, exp: Text Files and All files:

filter= "Text files (*.txt)|*.txt|All files (*.*)|*.*";

The select file  dialog box

The save file dialog box

(Use the Windows built-in dialog box).

res = commonDlg.ShowDlgSaveFile("C\\", "", "All | *.*", out pathName, out fileName);
if (res == CommonDlgResult.Ok)
{ ...}

The save file  dialog box

The images of these dialog boxes are the folder: Docs\Dialogs.