Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Microsoft C# Professional Projects - Premier Press.pdf
Скачиваний:
177
Добавлен:
24.05.2014
Размер:
14.65 Mб
Скачать

164 Project 1 CREATING A CUSTOMER MAINTENANCE PROJECT

FIGURE 8-15 MonthCalendar control and DateTimePicker control

Having learned about Windows applications in general, you can now apply the concepts to create a Windows application for the Customer Maintenance project.

Creating a Windows Application for the Customer Maintenance Project

As discussed earlier, you can create a Windows application by using the templates provided by Visual Studio .NET. Name the new project that you create Customer Maintenance Project. When you create the application, Visual Studio .NET creates a default form, Form1, for you. The following section describes adding controls to Form1.

WINDOWS FORMS AND CONTROLS

Chapter 8

165

 

 

 

Creating an Interface for Form1

1.Drag a Label control from the Windows Forms toolbox to the form.

2.Click on the Label control to change its properties.

If the Properties window is not displayed, click on the Properties Window option on the View menu. Alternatively, you can click the F4 key to display the Properties window.

3.Change the following properties of the control:

Text: Customer Maintenance System

Font:

Name: Microsoft Sans Serif

Size: 25

4.Drag a MainMenu control from the Windows Forms toolbox to the form.

A menu item is added to the form.

5.Click on the text Type Here and type the name of the first menu item as

&Worker.

Similarly, you can add more menu items to the form by typing in the area containing the text Type Here. You can add menu items for Customer, Job Details, Reports, and Exit. After adding menu items to the form, you need to change the properties of the menu items.

6.Click on the Worker menu item to change its properties.

7.In the Properties window, change the following properties of the Worker menu item.

Text: &Worker

Shortcut: AltW

Similarly, you can change the properties for the rest of the menu items. Table 8-2 shows the menu items and their corresponding property values.

166 Project 1 CREATING A CUSTOMER MAINTENANCE PROJECT

Table 8-2 Menu Items and their Corresponding Property Values

Menu Item

Property Value

Worker

Text: &Worker

 

Shortcut: AltW

Customer

Text: &Customer

 

Shortcut: AltC

Job Details

Text: &Job Details

 

Shortcut: AltJ

Reports

Text: &Reports

 

Shortcut: AltR

Exit

Text: E&xit

 

Shortcut: AltX

 

 

Figure 8-16 shows Form1 after the controls are added to it.

FIGURE 8-16 Form1 with the controls

Similarly, you can create an interface for the rest of the forms.

WINDOWS FORMS AND CONTROLS

Chapter 8

167

 

 

 

Creating an Interface for WorkerForm

WorkerForm is used to display the records in the Worker table. You can also add, modify, or delete records from this table by using WorkerForm. However, before creating an interface for WorkerForm, you need to add another form to the project. To add another form, perform the following steps.

1.Right-click on Customer Maintenance Project in the Solution Explorer window and select the Add option.

2.From the list that is displayed, select the Add New Item option. The Add New Item dialog box is displayed.

3.In the Templates: pane of the Add New Item dialog box, select the Windows Form icon.

4.In the Name text box, type the name of the form as WorkerForm and click on the Open button.

Visual Studio .NET creates a blank form with the name WorkerForm. You can now add controls to the form. To do so, perform the following steps:

1.Add a Label control, DataGrid control, and four button controls to the form.

2.In the Properties window, change the following properties of the controls:

Label control:

Name: label1

Text: Click on the Edit Button to load the records.

Font:

Name: Arial

Size: 10

Bold: True

Button1 control:

Name: btnSave

Text: Save