Chapter 02

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

Murach’s C# (8th Edition)

Chapter 2

How to design
a Windows
Forms app

© 2023, Mike Murach & Associates, Inc. C2, Slide 1


Objectives
Applied
1. Given the form design and property settings for a simple app, use
the Form Designer to design the form.
2. When necessary, rename the form, project, and solution files for
an app.
3. Customize the Visual Studio environment for use with C# by
setting the startup and development settings options.

Murach’s C# (8th Edition) C2, Slide 2


Objectives (continued)
Knowledge
1. Describe the use of the Toolbox and Properties windows.
2. Describe the Name and Text properties for a form or control.
3. Describe the Enabled, ReadOnly, and TextAlign properties for a
control.
4. Describe the way you:
Adjust the tab order for the controls on a form
Set access keys for controls
Set the default buttons for the Enter and Esc keys for a form

Murach’s C# (8th Edition) C2, Slide 3


The Create New Project dialog

Murach’s C# (8th Edition) C2, Slide 4


How to change the startup options
1. Use the ToolsàOptions command
2. Select the General category under the Environment group.
3. Select an option from the “On startup, open” drop-down list.

Murach’s C# (8th Edition) C2, Slide 5


How to change the development settings options
1. Select the ToolsàImport and Export Settings command.
2. Select “Reset all settings.”
3. Select “Yes, save my current settings” and the “Visual C#”
option as you step through the wizard.

Murach’s C# (8th Edition) C2, Slide 6


The Configure Your New Project dialog

Murach’s C# (8th Edition) C2, Slide 7


The Additional Information dialog

Murach’s C# (8th Edition) C2, Slide 8


The Invoice Total form

Murach’s C# (8th Edition) C2, Slide 9


The controls the Invoice Total form uses
• Labels
• Text boxes
• Buttons

Murach’s C# (8th Edition) C2, Slide 10


The Form Designer after some controls have been
added to the Invoice Total form

Murach’s C# (8th Edition) C2, Slide 11


Skills that you need for working with controls
• Add a control to a form
• Move a control
• Size a control
• Select a group of controls
• Align, size, or space a group of selected controls
• Change the size of a form
• Adjust the tab order for the controls on a form

Murach’s C# (8th Edition) C2, Slide 12


The Form Designer after the properties
for the Invoice Total form have been set

Murach’s C# (8th Edition) C2, Slide 13


Properties for forms and controls
Properties for both forms and controls
Name
Text

Other properties for forms


AcceptButton
CancelButton
StartPosition

Other properties for controls


Enabled
ReadOnly
TabIndex
TabStop
TextAlign

Murach’s C# (8th Edition) C2, Slide 14


How to adjust the tab order for a form
• Change a control’s TabIndex property.
• Set a control’s TabStop property to False if it shouldn’t receive
the focus.

Murach’s C# (8th Edition) C2, Slide 15


How to set access keys
• In the Text for a control, place an ampersand right before the
letter for the access key.
• If you set an access key for a label, the access key will take the
user to the text box that follows the label in the tab order.

Murach’s C# (8th Edition) C2, Slide 16


How to set the Enter and Esc keys
• Set the AcceptButton property of the form to the button that will
be activated if the user presses the Enter key.
• Set the CancelButton property of the form to the button that will
be activated when the user presses the Esc key.

Murach’s C# (8th Edition) C2, Slide 17


The Solution Explorer
as a form file is being renamed

Murach’s C# (8th Edition) C2, Slide 18


How to rename a file, project, or solution
• Right-click on it in the Solution Explorer window, and select the
Rename command from the shortcut menu.
• Or, select the file, project, or solution in the Solution Explorer
and press F2.

Murach’s C# (8th Edition) C2, Slide 19


How to save a file, project, or solution
• To save all files and projects, use the Save All button in the
Standard toolbar or the Save All command in the File menu.
• To save a file, project, or solution, use the Save button in the
Standard toolbar or the Save command in the File menu.

Murach’s C# (8th Edition) C2, Slide 20

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy