You display a dialog box in the same way you display any other form in an application. The startup form loads automatically when the application is run. To make a second form or dialog box appear in the application, write code to load and display it. Similarly, to make the form or dialog box disappear, write code to unload or hide it.
To display a dialog box
[Visual Basic] Private Sub Button1_Click() Dim dlg1 as new DialogBox dlg1.ShowDialog End Sub [C#] private void Button1_Click(object sender, EventArgs e) { MyDialogBox dlg1 = new MyDialogBox(); dlg1.ShowDialog(); }
For more information on the ways to show forms and dialog boxes, see Displaying Modal and Modeless Forms.
Dialog Boxes | Creating Dialog Boxes | Closing Dialog Boxes and Retaining User Input | Retrieving the Result for Dialog Boxes | Retrieving Dialog Box Information Selectively Using Multiple Properties | Retrieving Dialog Box Information Collectively Using Objects | Retrieving Information from the Parent Form of a Dialog Box