8.4. Dialog boxes

Windows forms can act as dialog boxes that are used to interact with users and retrieve information. To construct our own dialog box we create a new form, and set its FormBorderStyle property to FixedDialog or FixedToolWindow – this automatically removes unnecessary minimize, maximize, and system menu buttons. After this, we place the necessary controls and buttons on the form. Usually, we have Ok, Cancel, or Abort buttons in the dialog box. By associating the DialogResult property of each button with the appropriate DialogResult value, such as Ok, Cancel, and so on, we can specify the resulting action of the dialog box. This allows us to let the calling code know how it was closed.

Dialog boxes can be displayed either modally ...

Get A Programmer's Guide to .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.