A dialog box has the following characteristics:
- The only system button it is equipped with is Close . As the only system button, this button allows the user to dismiss the dialog and ignore whatever the user would have done on the dialog
box
- It cannot be minimized, maximized, or restored. A dialog box does not have any other system button but
Close
- It is usually modal, in which case the user is not allowed to continue any other operation on the same application until the dialog box is
dismissed
- It provides a way for the user to close or dismiss it
Practical
Learning: Introducing Dialog Boxes |
|
- Start Microsoft Visual C# and create a new Windows Application named SolasPropertyRental1
- From the Common Controls section of the Toolbox, click ListView and click
the form
- While the list view is still selected, in the Properties window,
change the following characteristics
(Name): lvwProperties
View: Details
- Still in the Properties window, click Columns and click its ellipsis
button
- In the ColumnHeader Collection Editor, click Add
- In the right list, click Text and type Property #
- Click Add.
In the right list, click Text and type Property Type
- Click Add.
In the right list, click Text and type Bedrooms
- Click Add.
In the right list, click Text and type Bathrooms
- Click Add.
In the right list, click Text and type Monthly Rent
- Click OK
- Complete the design of the form as follows:
|
Control |
Text |
Name |
ListView |
|
|
Button |
New Property... |
btnNewProperty |
Button |
Close |
btnClose |
|
- To add another form to the project, on the main menu, click Project ->
Add Windows Form...
- In the Templates list, make sure Windows Form is selected.
Set the Name to PropertyEditor and click Add
To create a dialog box, you start with a form,
which you can get by creating a Windows Application or deriving a
class from Form. Here is an example:
using System;
using System.Drawing;
using System.Windows.Forms;
public class Exercise : System.Windows.Forms.Form
{
public Exercise()
{
InitializeComponent();
}
private void InitializeComponent()
{
Text = "Domain Configuration";
Width = 320;
Height = 150;
Location = new Point(140, 100);
StartPosition = FormStartPosition.CenterScreen;
}
}
public class Program
{
static int Main()
{
System.Windows.Forms.Application.Run(new Exercise());
return 0;
}
}
This would produce:
|
|