SlideShare a Scribd company logo
1 of 31
Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 1
Chapter 2
How to design a
Windows Forms
application
Slide 2
Agenda
• Forms Basics
– Forms
– Controls
– Properties
Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 3
The Options dialog box for setting the project
options
Tools…Options
Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 4
The New Project dialog box
File…New…Project
Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 5
The Invoice Total form
Three types of controls
• A label displays text on a form.
• A text box lets the user enter text on a form.
• A button initiates form processing when clicked.
Text Box
Buttons
Labels
Slide 6
How the Invoice Total form works
• The user enters the subtotal into a text box, and the discount percent, discount
amount, and total are displayed in label controls. The discount percent is a function
of the amount of the subtotal.
• After entering a subtotal, the user can click the Calculate button to calculate the
discount percent, discount amount, and the total. Alternatively, the user can press
the Enter key to perform the calculation.
• To close the form and end the application, the user can click the Close button in the
upper right corner of the form or on the Exit button. Alternatively, the user can
press the Esc key to exit from the form.
• User can press Alt+C to access the Calculate button.
• User can press Alt+X to access the Exit button.
Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 7
Three ways to add a control to a form
• Select the control in the Toolbox. Then, click in the form where
you want to place the control. Or, drag the pointer on the form to
place the control and size it at the same time.
• Double-click the control in the Toolbox. Then, the control is
placed in the upper left corner of the form.
• Drag the control from the Toolbox and drop it on the form. Then,
the control is placed wherever you drop it.
Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 8
A form after some controls have been added to it
Slide 9
How to select and work with controls (basics)
• To select a control on a form, click on it. Careful…Don’t double
click or you’ll end up in the code editor.
• To move a control, drag it.
• To size a selected control, drag one of its handles.
• To select more than one control, hold down the Shift or Ctrl key
as you click on each control. Or, click on a blank spot in the form
and then dragging around the controls.
Slide 10
How to select and work with controls (Fancy Stuff)
• To align, size, or space a group of selected controls, click on a control
to make it the primary control. Then, use the commands in the Format
menu or the buttons on the Layout toolbar to align, size, or space the
controls relative to the primary control.
• You can also size all of the controls in a group by sizing the primary
control in the group. And you can drag any of the selected controls to
move all the controls.
• To change the size of a form to accommodate the controls, click on
the form and then drag it by one of its handles.
Slide 11
How to set properties (continued)
• When you click on a property in the Properties window, a brief
explanation of the property appears in a pane at the bottom of the
window. For more information, press F1 to display the help
information for the property.
• You can use the first two buttons at the top of the Properties
window to sort the properties by category or alphabetically.
• You can use the plus and minus signs displayed to the left of some
of the properties and categories in the Properties window to
expand and collapse the list of properties.
Note
• If a description isn’t displayed when you click on a property in the
Properties window, right-click on the window and select
Description from the shortcut menu.
Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 12
A form after the properties have been set
Tip: Set AutoSize to “False” &
BorderStyle to “Fixed3D”
before you clear out the Text
property if you are using labels
instead of textboxes.
Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 13
The Name property
• Sets the name you use to identify a control in your C# code.
• Can be changed to provide a more descriptive and memorable
name for forms and controls that you will refer to when you write
your code (such as text boxes and buttons).
• Doesn’t need to be changed for controls that you won’t refer to
when you write your code (such as most labels).
• Can use a three-letter prefix to indicate whether the name refers to
a form (frm), button (btn), label (lbl), or text box (txt).
Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 14
The Text property
• Sets the text that’s displayed on the form or control.
• For a form, the Text value is displayed in the title bar. For
controls, the Text value is displayed directly on the control.
• For a text box, the Text value changes when the user types text
into the control, and you can write code that uses the Text
property to get the text that was entered by the user.
Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 15
A form after the properties have been set
Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 16
Other properties for forms
Property Description
AcceptButton Identifies the button that will be activated when the
user presses the Enter key.
CancelButton Identifies the button that will be activated when the
user presses the Esc key.
StartPosition Sets the position at which the form is displayed. To
center the form, set this property to CenterScreen.
Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 17
Other properties for controls
Property Description
Enabled Determines whether the control will be enabled
or disabled.
ReadOnly Determines whether the text in some controls
like text boxes can be edited.
TabIndex Indicates the control’s position in the tab order,
which determines the order in which the controls
will receive the focus when the user presses the
Tab key.
TabStop Determines whether the control will accept the
focus when the user presses the Tab key to move
from one control to another. Some controls, like
labels, don’t have the TabStop property.
TextAlign Sets the alignment for the text displayed on a
control.
Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 18
How to adjust the tab order
• Tab order refers to the sequence in which the controls receive the
focus when the user presses the Tab key. You should adjust the
tab order so the Tab key moves the focus from one control to the
next in a logical sequence.
• Each control has a TabIndex property that indicates the control’s
position in the tab order. You can change this property to change a
control’s tab order position.
• If you don’t want a control to receive the focus when the user
presses the Tab key, change that control’s TabStop property to
False.
• Label controls don’t have a TabStop property so they can’t
receive the focus.
Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 19
How to set access keys
• Access keys are shortcut keys that the user can use in combination
with the Alt key to quickly move to individual controls on the
form.
• You use the Text property to set the access key for a control by
placing an ampersand immediately before the letter you want to
use for the access key.
• Since the access keys aren’t case sensitive, &N and &n set the
same access key.
• When you set access keys, make sure to use a unique letter for
each control.
• You can’t set the access key for a text box. However, if you set an
access key for a label that immediately precedes the text box in
the tab order, the access key will take the user to the text box.
Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 20
How to set the Enter and Esc keys
• The AcceptButton property of the form sets the button that will be
activated if the user presses the Enter key.
• The CancelButton property of the form sets the button that will be
activated if the user presses the Esc key. This property should
usually be set to the Exit button.
• You set the AcceptButton or CancelButton values by choosing the
button from a drop-down list that shows all of the buttons on the
form. So be sure to create and name the buttons you want to use
before you attempt to set these values.
Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 21
The property settings for the form
Default name Property Setting
Form1 Text Invoice Total
AcceptButton btnCalculate
CancelButton btnExit
StartPosition CenterScreen
Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 22
The property settings for the controls
Default name Property Setting
label1 Text &Subtotal:
TextAlign MiddleLeft
TabIndex 0
label2 Text Discount percent:
TextAlign MiddleLeft
label3 Text Discount amount:
TextAlign MiddleLeft
label4 Text Total:
TextAlign MiddleLeft
Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 23
The property settings for the controls (continued)
Default name Property Setting
textBox1 Name txtSubtotal
TabIndex 1
textBox2 Name txtDiscountPercent
ReadOnly True
TabStop False
textBox3 Name txtDiscountAmount
ReadOnly True
TabStop False
textBox4 Name txtTotal
ReadOnly True
TabStop False
Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 24
The property settings for the controls (continued)
Default name Property Setting
button1 Name btnCalculate
Text &Calculate
TabIndex 2
button2 Name btnExit
Text E&xit
TabIndex 3
Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 25
The Solution Explorer as a form file is being
renamed
Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 26
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 it in the
Solution Explorer and press F2. Then, you can enter the new
name.
• Be sure not to change or omit the file extension when you rename
a file. Remember too that using a three-letter prefix to indicate the
contents of the file (like frm for a form file) makes it easier to tell
what each file represents.
• When you change the name of a form file, Visual Studio will also
change the Name property for the form and update any references
within the existing code for the form.
Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 27
How to save a file, project, or solution
• You can use the Save All button in the Standard toolbar or the
Save All command in the File menu to save all files and projects
in the solution.
• You can use the Save button in the Standard toolbar or the Save
command in the File menu to save a file, project, or solution. The
files that are saved depend on what’s selected in the Solution
Explorer window. If a single file is selected, just that file is saved.
If a project is selected, the entire project and its solution are saved.
And if a solution is selected, the entire solution and all its projects
are saved.
• If you try to close a solution that contains modified files, a dialog
box is displayed that asks you if you want to save those files.
Slide 28
In-Class Activity
• Create the following form
– Note:
• Form title
• Justification of fields
• The “Enter” key and the Alt+C keys do the same
thing as pressing the “Calculate Letter Grade”
button
• The “Esc” key and Alt+X keys do the same thing as
pressing the “Exit” button
• Don’t forget the tab order.
– We’ll work on this program again later
Text box
Label
Slide 29
In-Class Activity
• Create the following form
– Note:
• Form title
• Justification of fields
• The “Enter” key and the Alt+C keys do the same
thing as pressing the “Calculate Grand Total” button
• The “Esc” key and Alt+X keys do the same thing as
pressing the “Exit” button
• Don’t forget the tab order
– We’ll work on this program again later
Text boxes
Read Only
Text Boxes
Slide 30
In-Class Activity
• Create the following form
– Note:
• Form title
• Justification of fields
• The “Enter” key and the Alt+P keys do the same
thing as pressing the “Project Student Population”
button
• The “Esc” key and Alt+X keys do the same thing as
pressing the “Exit” button
• Don’t forget the tab order
– We’ll work on this program again later
Text boxes
Read Only
Text Box
Slide 31
In-Class Activity
• Create the following form
– Note:
• Form title
• Justification of fields
• The “Enter” key and the Alt+C keys do the same
thing as pressing the “Convert to Numeric Only”
button
• The “Esc” key and Alt+X keys do the same thing as
pressing the “Exit” button
• Don’t forget the tab order
– We’ll work on this program again later
Read Only
Text Box
Text box

More Related Content

What's hot

Web design - Working with tables in HTML
Web design - Working with tables in HTMLWeb design - Working with tables in HTML
Web design - Working with tables in HTMLMustafa Kamel Mohammadi
 
VB Multiple Forms
VB Multiple FormsVB Multiple Forms
VB Multiple Formsobrienduke
 
Component object model and
Component object model andComponent object model and
Component object model andSaransh Garg
 
Word 2013 Unit A
Word 2013 Unit AWord 2013 Unit A
Word 2013 Unit Ajarana00
 
How to make a Power Point
How to make a Power PointHow to make a Power Point
How to make a Power Pointguest393c4e
 
Autocad lezione 4
Autocad lezione 4Autocad lezione 4
Autocad lezione 4Carella2014
 
7. check box control
7. check box control7. check box control
7. check box controlchauhankapil
 
Excel shortcut
Excel shortcutExcel shortcut
Excel shortcutASIF KHAN
 
Apply Bold, Italic and Underline to Selected Text in a RichtextBox using Visu...
Apply Bold, Italic and Underline to Selected Text in a RichtextBox using Visu...Apply Bold, Italic and Underline to Selected Text in a RichtextBox using Visu...
Apply Bold, Italic and Underline to Selected Text in a RichtextBox using Visu...Daniel DotNet
 
How to create a power point presentation
How to create a power point presentationHow to create a power point presentation
How to create a power point presentationJchadwell
 
Literals,variables,datatype in C#
Literals,variables,datatype in C#Literals,variables,datatype in C#
Literals,variables,datatype in C#Prasanna Kumar SM
 
Autocad lezione 3
Autocad lezione 3Autocad lezione 3
Autocad lezione 3Carella2014
 
Font dialog & link label
Font dialog & link labelFont dialog & link label
Font dialog & link labelchauhankapil
 

What's hot (20)

Web design - Working with tables in HTML
Web design - Working with tables in HTMLWeb design - Working with tables in HTML
Web design - Working with tables in HTML
 
4.C#
4.C#4.C#
4.C#
 
VB Multiple Forms
VB Multiple FormsVB Multiple Forms
VB Multiple Forms
 
Component object model and
Component object model andComponent object model and
Component object model and
 
Word 2013 Unit A
Word 2013 Unit AWord 2013 Unit A
Word 2013 Unit A
 
Ms word
Ms wordMs word
Ms word
 
How to make a Power Point
How to make a Power PointHow to make a Power Point
How to make a Power Point
 
Textbox n label
Textbox n labelTextbox n label
Textbox n label
 
Autocad lezione 4
Autocad lezione 4Autocad lezione 4
Autocad lezione 4
 
Microsoft word
Microsoft wordMicrosoft word
Microsoft word
 
7. check box control
7. check box control7. check box control
7. check box control
 
Excel shortcut
Excel shortcutExcel shortcut
Excel shortcut
 
android menus
android menusandroid menus
android menus
 
Apply Bold, Italic and Underline to Selected Text in a RichtextBox using Visu...
Apply Bold, Italic and Underline to Selected Text in a RichtextBox using Visu...Apply Bold, Italic and Underline to Selected Text in a RichtextBox using Visu...
Apply Bold, Italic and Underline to Selected Text in a RichtextBox using Visu...
 
Visual Basic 6.0
Visual Basic 6.0Visual Basic 6.0
Visual Basic 6.0
 
How to create a power point presentation
How to create a power point presentationHow to create a power point presentation
How to create a power point presentation
 
Literals,variables,datatype in C#
Literals,variables,datatype in C#Literals,variables,datatype in C#
Literals,variables,datatype in C#
 
Autocad lezione 3
Autocad lezione 3Autocad lezione 3
Autocad lezione 3
 
HTML practical file
HTML practical fileHTML practical file
HTML practical file
 
Font dialog & link label
Font dialog & link labelFont dialog & link label
Font dialog & link label
 

Viewers also liked

C# Tutorial MSM_Murach chapter-04-slides
C# Tutorial MSM_Murach chapter-04-slidesC# Tutorial MSM_Murach chapter-04-slides
C# Tutorial MSM_Murach chapter-04-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-01-slides
C# Tutorial MSM_Murach chapter-01-slidesC# Tutorial MSM_Murach chapter-01-slides
C# Tutorial MSM_Murach chapter-01-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-03-slides
C# Tutorial MSM_Murach chapter-03-slidesC# Tutorial MSM_Murach chapter-03-slides
C# Tutorial MSM_Murach chapter-03-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-16-slides
C# Tutorial MSM_Murach chapter-16-slidesC# Tutorial MSM_Murach chapter-16-slides
C# Tutorial MSM_Murach chapter-16-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-13-slides
C# Tutorial MSM_Murach chapter-13-slidesC# Tutorial MSM_Murach chapter-13-slides
C# Tutorial MSM_Murach chapter-13-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-07-slides
C# Tutorial MSM_Murach chapter-07-slidesC# Tutorial MSM_Murach chapter-07-slides
C# Tutorial MSM_Murach chapter-07-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-12-slides
C# Tutorial MSM_Murach chapter-12-slidesC# Tutorial MSM_Murach chapter-12-slides
C# Tutorial MSM_Murach chapter-12-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-20-slides
C# Tutorial MSM_Murach chapter-20-slidesC# Tutorial MSM_Murach chapter-20-slides
C# Tutorial MSM_Murach chapter-20-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-23-slides
C# Tutorial MSM_Murach chapter-23-slidesC# Tutorial MSM_Murach chapter-23-slides
C# Tutorial MSM_Murach chapter-23-slidesSami Mut
 
SSL5 Energy Transfer and Analysis
SSL5 Energy Transfer and AnalysisSSL5 Energy Transfer and Analysis
SSL5 Energy Transfer and AnalysisKeith Vaugh
 
C# Tutorial MSM_Murach chapter-11-slides
C# Tutorial MSM_Murach chapter-11-slidesC# Tutorial MSM_Murach chapter-11-slides
C# Tutorial MSM_Murach chapter-11-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-10-slides
C# Tutorial MSM_Murach chapter-10-slidesC# Tutorial MSM_Murach chapter-10-slides
C# Tutorial MSM_Murach chapter-10-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-06-slides
C# Tutorial MSM_Murach chapter-06-slidesC# Tutorial MSM_Murach chapter-06-slides
C# Tutorial MSM_Murach chapter-06-slidesSami Mut
 

Viewers also liked (16)

C# Tutorial MSM_Murach chapter-04-slides
C# Tutorial MSM_Murach chapter-04-slidesC# Tutorial MSM_Murach chapter-04-slides
C# Tutorial MSM_Murach chapter-04-slides
 
C# Tutorial MSM_Murach chapter-01-slides
C# Tutorial MSM_Murach chapter-01-slidesC# Tutorial MSM_Murach chapter-01-slides
C# Tutorial MSM_Murach chapter-01-slides
 
C# Tutorial MSM_Murach chapter-03-slides
C# Tutorial MSM_Murach chapter-03-slidesC# Tutorial MSM_Murach chapter-03-slides
C# Tutorial MSM_Murach chapter-03-slides
 
C# Tutorial MSM_Murach chapter-16-slides
C# Tutorial MSM_Murach chapter-16-slidesC# Tutorial MSM_Murach chapter-16-slides
C# Tutorial MSM_Murach chapter-16-slides
 
C# Tutorial MSM_Murach chapter-13-slides
C# Tutorial MSM_Murach chapter-13-slidesC# Tutorial MSM_Murach chapter-13-slides
C# Tutorial MSM_Murach chapter-13-slides
 
C# Tutorial MSM_Murach chapter-07-slides
C# Tutorial MSM_Murach chapter-07-slidesC# Tutorial MSM_Murach chapter-07-slides
C# Tutorial MSM_Murach chapter-07-slides
 
C# Tutorial MSM_Murach chapter-12-slides
C# Tutorial MSM_Murach chapter-12-slidesC# Tutorial MSM_Murach chapter-12-slides
C# Tutorial MSM_Murach chapter-12-slides
 
C# Tutorial MSM_Murach chapter-20-slides
C# Tutorial MSM_Murach chapter-20-slidesC# Tutorial MSM_Murach chapter-20-slides
C# Tutorial MSM_Murach chapter-20-slides
 
C# Tutorial MSM_Murach chapter-23-slides
C# Tutorial MSM_Murach chapter-23-slidesC# Tutorial MSM_Murach chapter-23-slides
C# Tutorial MSM_Murach chapter-23-slides
 
SSL5 Energy Transfer and Analysis
SSL5 Energy Transfer and AnalysisSSL5 Energy Transfer and Analysis
SSL5 Energy Transfer and Analysis
 
tutotial netbeans
tutotial netbeanstutotial netbeans
tutotial netbeans
 
C# Tutorial MSM_Murach chapter-11-slides
C# Tutorial MSM_Murach chapter-11-slidesC# Tutorial MSM_Murach chapter-11-slides
C# Tutorial MSM_Murach chapter-11-slides
 
MSM_Time
MSM_TimeMSM_Time
MSM_Time
 
C# Tutorial MSM_Murach chapter-10-slides
C# Tutorial MSM_Murach chapter-10-slidesC# Tutorial MSM_Murach chapter-10-slides
C# Tutorial MSM_Murach chapter-10-slides
 
C# Tutorial MSM_Murach chapter-06-slides
C# Tutorial MSM_Murach chapter-06-slidesC# Tutorial MSM_Murach chapter-06-slides
C# Tutorial MSM_Murach chapter-06-slides
 
Course Wikis
Course WikisCourse Wikis
Course Wikis
 

Similar to C# Tutorial MSM_Murach chapter-02-slides

C# Tutorial MSM_Murach chapter-24-slides
C# Tutorial MSM_Murach chapter-24-slidesC# Tutorial MSM_Murach chapter-24-slides
C# Tutorial MSM_Murach chapter-24-slidesSami Mut
 
The visual studio start page is shown in the figure below
The visual studio start page is shown in the figure belowThe visual studio start page is shown in the figure below
The visual studio start page is shown in the figure belowTan Ps
 
Shelly Cashman Excel 2013 Chapter 10 SAM Project 1aShelly .docx
Shelly Cashman Excel 2013 Chapter 10 SAM Project 1aShelly .docxShelly Cashman Excel 2013 Chapter 10 SAM Project 1aShelly .docx
Shelly Cashman Excel 2013 Chapter 10 SAM Project 1aShelly .docxmaoanderton
 
Csc153 chapter 03
Csc153 chapter 03Csc153 chapter 03
Csc153 chapter 03PCC
 
Final Project Part 1 (Videos Form) Create this.docx
Final Project   Part 1 (Videos Form) Create this.docxFinal Project   Part 1 (Videos Form) Create this.docx
Final Project Part 1 (Videos Form) Create this.docxmydrynan
 
How to design a report with fine report reporting tool
How to design a report with  fine report reporting toolHow to design a report with  fine report reporting tool
How to design a report with fine report reporting toolFineReport Reporting Tool
 
Getting started with the visual basic editor
Getting started with the visual basic editorGetting started with the visual basic editor
Getting started with the visual basic editorputiadetiara
 
Data presentation and reporting cognos tm1
Data presentation and reporting cognos tm1Data presentation and reporting cognos tm1
Data presentation and reporting cognos tm1veeracynixit
 
Computer applications in business assignment
Computer applications in business assignmentComputer applications in business assignment
Computer applications in business assignmentYogesh Singla
 
Chapter.03
Chapter.03Chapter.03
Chapter.03klivsie
 

Similar to C# Tutorial MSM_Murach chapter-02-slides (20)

Chapter 02
Chapter 02Chapter 02
Chapter 02
 
Visual C# 2010
Visual C# 2010Visual C# 2010
Visual C# 2010
 
C# Tutorial MSM_Murach chapter-24-slides
C# Tutorial MSM_Murach chapter-24-slidesC# Tutorial MSM_Murach chapter-24-slides
C# Tutorial MSM_Murach chapter-24-slides
 
The visual studio start page is shown in the figure below
The visual studio start page is shown in the figure belowThe visual studio start page is shown in the figure below
The visual studio start page is shown in the figure below
 
Visual basic
Visual basicVisual basic
Visual basic
 
Visual Basic.pptx
Visual Basic.pptxVisual Basic.pptx
Visual Basic.pptx
 
2 front panel
2  front panel2  front panel
2 front panel
 
Shelly Cashman Excel 2013 Chapter 10 SAM Project 1aShelly .docx
Shelly Cashman Excel 2013 Chapter 10 SAM Project 1aShelly .docxShelly Cashman Excel 2013 Chapter 10 SAM Project 1aShelly .docx
Shelly Cashman Excel 2013 Chapter 10 SAM Project 1aShelly .docx
 
Csc153 chapter 03
Csc153 chapter 03Csc153 chapter 03
Csc153 chapter 03
 
Tugas testing
Tugas testingTugas testing
Tugas testing
 
Final Project Part 1 (Videos Form) Create this.docx
Final Project   Part 1 (Videos Form) Create this.docxFinal Project   Part 1 (Videos Form) Create this.docx
Final Project Part 1 (Videos Form) Create this.docx
 
Tutorials2
Tutorials2Tutorials2
Tutorials2
 
OpenCastLabs Excel chapter-3
OpenCastLabs Excel chapter-3OpenCastLabs Excel chapter-3
OpenCastLabs Excel chapter-3
 
How to design a report with fine report reporting tool
How to design a report with  fine report reporting toolHow to design a report with  fine report reporting tool
How to design a report with fine report reporting tool
 
Getting started with the visual basic editor
Getting started with the visual basic editorGetting started with the visual basic editor
Getting started with the visual basic editor
 
Data presentation and reporting cognos tm1
Data presentation and reporting cognos tm1Data presentation and reporting cognos tm1
Data presentation and reporting cognos tm1
 
Computer applications in business assignment
Computer applications in business assignmentComputer applications in business assignment
Computer applications in business assignment
 
Chapter.03
Chapter.03Chapter.03
Chapter.03
 
Chapter.03
Chapter.03Chapter.03
Chapter.03
 
Vp lecture1 ararat
Vp lecture1 araratVp lecture1 ararat
Vp lecture1 ararat
 

More from Sami Mut

C# Tutorial MSM_Murach chapter-25-slides
C# Tutorial MSM_Murach chapter-25-slidesC# Tutorial MSM_Murach chapter-25-slides
C# Tutorial MSM_Murach chapter-25-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-22-slides
C# Tutorial MSM_Murach chapter-22-slidesC# Tutorial MSM_Murach chapter-22-slides
C# Tutorial MSM_Murach chapter-22-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-21-slides
C# Tutorial MSM_Murach chapter-21-slidesC# Tutorial MSM_Murach chapter-21-slides
C# Tutorial MSM_Murach chapter-21-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-19-slides
C# Tutorial MSM_Murach chapter-19-slidesC# Tutorial MSM_Murach chapter-19-slides
C# Tutorial MSM_Murach chapter-19-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-17-slides
C# Tutorial MSM_Murach chapter-17-slidesC# Tutorial MSM_Murach chapter-17-slides
C# Tutorial MSM_Murach chapter-17-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-18-slides
C# Tutorial MSM_Murach chapter-18-slidesC# Tutorial MSM_Murach chapter-18-slides
C# Tutorial MSM_Murach chapter-18-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-15-slides
C# Tutorial MSM_Murach chapter-15-slidesC# Tutorial MSM_Murach chapter-15-slides
C# Tutorial MSM_Murach chapter-15-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-14-slides
C# Tutorial MSM_Murach chapter-14-slidesC# Tutorial MSM_Murach chapter-14-slides
C# Tutorial MSM_Murach chapter-14-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-09-slides
C# Tutorial MSM_Murach chapter-09-slidesC# Tutorial MSM_Murach chapter-09-slides
C# Tutorial MSM_Murach chapter-09-slidesSami Mut
 
C# Tutorial MSM_Murach chapter-08-slides
C# Tutorial MSM_Murach chapter-08-slidesC# Tutorial MSM_Murach chapter-08-slides
C# Tutorial MSM_Murach chapter-08-slidesSami Mut
 
chapter 5 Java at rupp cambodia
chapter 5 Java at rupp cambodiachapter 5 Java at rupp cambodia
chapter 5 Java at rupp cambodiaSami Mut
 
chapter 2 Java at rupp cambodia
chapter 2 Java at rupp cambodiachapter 2 Java at rupp cambodia
chapter 2 Java at rupp cambodiaSami Mut
 
chapter 3 Java at rupp cambodia
chapter 3 Java at rupp cambodiachapter 3 Java at rupp cambodia
chapter 3 Java at rupp cambodiaSami Mut
 
chapter 2 Java at rupp cambodia
chapter 2 Java at rupp cambodiachapter 2 Java at rupp cambodia
chapter 2 Java at rupp cambodiaSami Mut
 
chapter 1 Java at rupp cambodia
chapter 1 Java at rupp cambodiachapter 1 Java at rupp cambodia
chapter 1 Java at rupp cambodiaSami Mut
 

More from Sami Mut (15)

C# Tutorial MSM_Murach chapter-25-slides
C# Tutorial MSM_Murach chapter-25-slidesC# Tutorial MSM_Murach chapter-25-slides
C# Tutorial MSM_Murach chapter-25-slides
 
C# Tutorial MSM_Murach chapter-22-slides
C# Tutorial MSM_Murach chapter-22-slidesC# Tutorial MSM_Murach chapter-22-slides
C# Tutorial MSM_Murach chapter-22-slides
 
C# Tutorial MSM_Murach chapter-21-slides
C# Tutorial MSM_Murach chapter-21-slidesC# Tutorial MSM_Murach chapter-21-slides
C# Tutorial MSM_Murach chapter-21-slides
 
C# Tutorial MSM_Murach chapter-19-slides
C# Tutorial MSM_Murach chapter-19-slidesC# Tutorial MSM_Murach chapter-19-slides
C# Tutorial MSM_Murach chapter-19-slides
 
C# Tutorial MSM_Murach chapter-17-slides
C# Tutorial MSM_Murach chapter-17-slidesC# Tutorial MSM_Murach chapter-17-slides
C# Tutorial MSM_Murach chapter-17-slides
 
C# Tutorial MSM_Murach chapter-18-slides
C# Tutorial MSM_Murach chapter-18-slidesC# Tutorial MSM_Murach chapter-18-slides
C# Tutorial MSM_Murach chapter-18-slides
 
C# Tutorial MSM_Murach chapter-15-slides
C# Tutorial MSM_Murach chapter-15-slidesC# Tutorial MSM_Murach chapter-15-slides
C# Tutorial MSM_Murach chapter-15-slides
 
C# Tutorial MSM_Murach chapter-14-slides
C# Tutorial MSM_Murach chapter-14-slidesC# Tutorial MSM_Murach chapter-14-slides
C# Tutorial MSM_Murach chapter-14-slides
 
C# Tutorial MSM_Murach chapter-09-slides
C# Tutorial MSM_Murach chapter-09-slidesC# Tutorial MSM_Murach chapter-09-slides
C# Tutorial MSM_Murach chapter-09-slides
 
C# Tutorial MSM_Murach chapter-08-slides
C# Tutorial MSM_Murach chapter-08-slidesC# Tutorial MSM_Murach chapter-08-slides
C# Tutorial MSM_Murach chapter-08-slides
 
chapter 5 Java at rupp cambodia
chapter 5 Java at rupp cambodiachapter 5 Java at rupp cambodia
chapter 5 Java at rupp cambodia
 
chapter 2 Java at rupp cambodia
chapter 2 Java at rupp cambodiachapter 2 Java at rupp cambodia
chapter 2 Java at rupp cambodia
 
chapter 3 Java at rupp cambodia
chapter 3 Java at rupp cambodiachapter 3 Java at rupp cambodia
chapter 3 Java at rupp cambodia
 
chapter 2 Java at rupp cambodia
chapter 2 Java at rupp cambodiachapter 2 Java at rupp cambodia
chapter 2 Java at rupp cambodia
 
chapter 1 Java at rupp cambodia
chapter 1 Java at rupp cambodiachapter 1 Java at rupp cambodia
chapter 1 Java at rupp cambodia
 

Recently uploaded

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Recently uploaded (20)

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

C# Tutorial MSM_Murach chapter-02-slides

  • 1. Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 1 Chapter 2 How to design a Windows Forms application
  • 2. Slide 2 Agenda • Forms Basics – Forms – Controls – Properties
  • 3. Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 3 The Options dialog box for setting the project options Tools…Options
  • 4. Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 4 The New Project dialog box File…New…Project
  • 5. Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 5 The Invoice Total form Three types of controls • A label displays text on a form. • A text box lets the user enter text on a form. • A button initiates form processing when clicked. Text Box Buttons Labels
  • 6. Slide 6 How the Invoice Total form works • The user enters the subtotal into a text box, and the discount percent, discount amount, and total are displayed in label controls. The discount percent is a function of the amount of the subtotal. • After entering a subtotal, the user can click the Calculate button to calculate the discount percent, discount amount, and the total. Alternatively, the user can press the Enter key to perform the calculation. • To close the form and end the application, the user can click the Close button in the upper right corner of the form or on the Exit button. Alternatively, the user can press the Esc key to exit from the form. • User can press Alt+C to access the Calculate button. • User can press Alt+X to access the Exit button.
  • 7. Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 7 Three ways to add a control to a form • Select the control in the Toolbox. Then, click in the form where you want to place the control. Or, drag the pointer on the form to place the control and size it at the same time. • Double-click the control in the Toolbox. Then, the control is placed in the upper left corner of the form. • Drag the control from the Toolbox and drop it on the form. Then, the control is placed wherever you drop it.
  • 8. Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 8 A form after some controls have been added to it
  • 9. Slide 9 How to select and work with controls (basics) • To select a control on a form, click on it. Careful…Don’t double click or you’ll end up in the code editor. • To move a control, drag it. • To size a selected control, drag one of its handles. • To select more than one control, hold down the Shift or Ctrl key as you click on each control. Or, click on a blank spot in the form and then dragging around the controls.
  • 10. Slide 10 How to select and work with controls (Fancy Stuff) • To align, size, or space a group of selected controls, click on a control to make it the primary control. Then, use the commands in the Format menu or the buttons on the Layout toolbar to align, size, or space the controls relative to the primary control. • You can also size all of the controls in a group by sizing the primary control in the group. And you can drag any of the selected controls to move all the controls. • To change the size of a form to accommodate the controls, click on the form and then drag it by one of its handles.
  • 11. Slide 11 How to set properties (continued) • When you click on a property in the Properties window, a brief explanation of the property appears in a pane at the bottom of the window. For more information, press F1 to display the help information for the property. • You can use the first two buttons at the top of the Properties window to sort the properties by category or alphabetically. • You can use the plus and minus signs displayed to the left of some of the properties and categories in the Properties window to expand and collapse the list of properties. Note • If a description isn’t displayed when you click on a property in the Properties window, right-click on the window and select Description from the shortcut menu.
  • 12. Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 12 A form after the properties have been set Tip: Set AutoSize to “False” & BorderStyle to “Fixed3D” before you clear out the Text property if you are using labels instead of textboxes.
  • 13. Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 13 The Name property • Sets the name you use to identify a control in your C# code. • Can be changed to provide a more descriptive and memorable name for forms and controls that you will refer to when you write your code (such as text boxes and buttons). • Doesn’t need to be changed for controls that you won’t refer to when you write your code (such as most labels). • Can use a three-letter prefix to indicate whether the name refers to a form (frm), button (btn), label (lbl), or text box (txt).
  • 14. Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 14 The Text property • Sets the text that’s displayed on the form or control. • For a form, the Text value is displayed in the title bar. For controls, the Text value is displayed directly on the control. • For a text box, the Text value changes when the user types text into the control, and you can write code that uses the Text property to get the text that was entered by the user.
  • 15. Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 15 A form after the properties have been set
  • 16. Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 16 Other properties for forms Property Description AcceptButton Identifies the button that will be activated when the user presses the Enter key. CancelButton Identifies the button that will be activated when the user presses the Esc key. StartPosition Sets the position at which the form is displayed. To center the form, set this property to CenterScreen.
  • 17. Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 17 Other properties for controls Property Description Enabled Determines whether the control will be enabled or disabled. ReadOnly Determines whether the text in some controls like text boxes can be edited. TabIndex Indicates the control’s position in the tab order, which determines the order in which the controls will receive the focus when the user presses the Tab key. TabStop Determines whether the control will accept the focus when the user presses the Tab key to move from one control to another. Some controls, like labels, don’t have the TabStop property. TextAlign Sets the alignment for the text displayed on a control.
  • 18. Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 18 How to adjust the tab order • Tab order refers to the sequence in which the controls receive the focus when the user presses the Tab key. You should adjust the tab order so the Tab key moves the focus from one control to the next in a logical sequence. • Each control has a TabIndex property that indicates the control’s position in the tab order. You can change this property to change a control’s tab order position. • If you don’t want a control to receive the focus when the user presses the Tab key, change that control’s TabStop property to False. • Label controls don’t have a TabStop property so they can’t receive the focus.
  • 19. Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 19 How to set access keys • Access keys are shortcut keys that the user can use in combination with the Alt key to quickly move to individual controls on the form. • You use the Text property to set the access key for a control by placing an ampersand immediately before the letter you want to use for the access key. • Since the access keys aren’t case sensitive, &N and &n set the same access key. • When you set access keys, make sure to use a unique letter for each control. • You can’t set the access key for a text box. However, if you set an access key for a label that immediately precedes the text box in the tab order, the access key will take the user to the text box.
  • 20. Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 20 How to set the Enter and Esc keys • The AcceptButton property of the form sets the button that will be activated if the user presses the Enter key. • The CancelButton property of the form sets the button that will be activated if the user presses the Esc key. This property should usually be set to the Exit button. • You set the AcceptButton or CancelButton values by choosing the button from a drop-down list that shows all of the buttons on the form. So be sure to create and name the buttons you want to use before you attempt to set these values.
  • 21. Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 21 The property settings for the form Default name Property Setting Form1 Text Invoice Total AcceptButton btnCalculate CancelButton btnExit StartPosition CenterScreen
  • 22. Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 22 The property settings for the controls Default name Property Setting label1 Text &Subtotal: TextAlign MiddleLeft TabIndex 0 label2 Text Discount percent: TextAlign MiddleLeft label3 Text Discount amount: TextAlign MiddleLeft label4 Text Total: TextAlign MiddleLeft
  • 23. Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 23 The property settings for the controls (continued) Default name Property Setting textBox1 Name txtSubtotal TabIndex 1 textBox2 Name txtDiscountPercent ReadOnly True TabStop False textBox3 Name txtDiscountAmount ReadOnly True TabStop False textBox4 Name txtTotal ReadOnly True TabStop False
  • 24. Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 24 The property settings for the controls (continued) Default name Property Setting button1 Name btnCalculate Text &Calculate TabIndex 2 button2 Name btnExit Text E&xit TabIndex 3
  • 25. Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 25 The Solution Explorer as a form file is being renamed
  • 26. Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 26 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 it in the Solution Explorer and press F2. Then, you can enter the new name. • Be sure not to change or omit the file extension when you rename a file. Remember too that using a three-letter prefix to indicate the contents of the file (like frm for a form file) makes it easier to tell what each file represents. • When you change the name of a form file, Visual Studio will also change the Name property for the form and update any references within the existing code for the form.
  • 27. Murach’s C# 2010, C2 © 2010, Mike Murach & Associates, Inc. Slide 27 How to save a file, project, or solution • You can use the Save All button in the Standard toolbar or the Save All command in the File menu to save all files and projects in the solution. • You can use the Save button in the Standard toolbar or the Save command in the File menu to save a file, project, or solution. The files that are saved depend on what’s selected in the Solution Explorer window. If a single file is selected, just that file is saved. If a project is selected, the entire project and its solution are saved. And if a solution is selected, the entire solution and all its projects are saved. • If you try to close a solution that contains modified files, a dialog box is displayed that asks you if you want to save those files.
  • 28. Slide 28 In-Class Activity • Create the following form – Note: • Form title • Justification of fields • The “Enter” key and the Alt+C keys do the same thing as pressing the “Calculate Letter Grade” button • The “Esc” key and Alt+X keys do the same thing as pressing the “Exit” button • Don’t forget the tab order. – We’ll work on this program again later Text box Label
  • 29. Slide 29 In-Class Activity • Create the following form – Note: • Form title • Justification of fields • The “Enter” key and the Alt+C keys do the same thing as pressing the “Calculate Grand Total” button • The “Esc” key and Alt+X keys do the same thing as pressing the “Exit” button • Don’t forget the tab order – We’ll work on this program again later Text boxes Read Only Text Boxes
  • 30. Slide 30 In-Class Activity • Create the following form – Note: • Form title • Justification of fields • The “Enter” key and the Alt+P keys do the same thing as pressing the “Project Student Population” button • The “Esc” key and Alt+X keys do the same thing as pressing the “Exit” button • Don’t forget the tab order – We’ll work on this program again later Text boxes Read Only Text Box
  • 31. Slide 31 In-Class Activity • Create the following form – Note: • Form title • Justification of fields • The “Enter” key and the Alt+C keys do the same thing as pressing the “Convert to Numeric Only” button • The “Esc” key and Alt+X keys do the same thing as pressing the “Exit” button • Don’t forget the tab order – We’ll work on this program again later Read Only Text Box Text box