[go: up one dir, main page]

0% found this document useful (0 votes)
48 views23 pages

C# Chapter 2

This document introduces various controls that can be used in programming with Visual C#. It describes label controls for providing descriptive text, text boxes for user input, clearing text boxes, masked text boxes for specifying input formats, rich text boxes for formatting text, check boxes for selecting options, radio buttons for single selection among groups, combo boxes, picture boxes for images, tooltips, naming controls, setting visibility at runtime, and disabling controls.

Uploaded by

Salman Sead
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views23 pages

C# Chapter 2

This document introduces various controls that can be used in programming with Visual C#. It describes label controls for providing descriptive text, text boxes for user input, clearing text boxes, masked text boxes for specifying input formats, rich text boxes for formatting text, check boxes for selecting options, radio buttons for single selection among groups, combo boxes, picture boxes for images, tooltips, naming controls, setting visibility at runtime, and disabling controls.

Uploaded by

Salman Sead
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 23

Programming with Visual C#

Chapter 2

Introducing Controls
Introducing Controls
Labels
 Label controls are typically used to provide
descriptive text for a control.
Text Boxes
 Use a text box control when you want the user to
type some input.
Text Boxes
 You can use the Text property of each text
box.
Clearing Text Boxes and Labels
 You can clear out the contents of a text box or
label by setting the property to an empty string .
Use "" (no space between the two quotation
marks). This empty string is also called a null
string or zero-length string .
 You also can clear out a text box using the Clear
method.
Masked Text Boxes
 A specialized form of the TextBox control is the
MaskedTextBox .
 You can specify the format (the Mask property) of
the data required of the user.
 For example, you can select a mask for a ZIP
code, a date, a phone number, or a social security
number.
Input mask for Masked Text Boxes
Rich Text Boxes
 RichTextBox offers several formatting features
(the user can apply character and paragraph
formatting to selected text, much like using a word
processor)
Check Boxes
 Check boxes allow the user to select (or deselect) an
option. In any group of check boxes, any number can be
selected.
 The Checked property of a check box is set to false if
unchecked or true if checked. You can write an event
handler for the CheckedChanged event, which executes
when the user clicks in the box.
Check Box
Radio Buttons
 Use radio buttons when only one button of a group may be
selected.
 A group of radio buttons inside a group box function
together.
 The best method is to first create a group box and then create
each radio button inside the group box.
 The Checked property of a radio button is set to true if
selected or to false if unselected.
 You can write an event handler to execute when the user
selects a radio button using the control’s CheckedChanged
event
Radio Buttons with Group box
Combo Box
Picture Boxes
 A PictureBox control can hold an image. You can set a
picture box’s Image property to a graphic file with an
extension of .bmp, .gif, .jpg, .jpeg, .png, .ico, .emf,
or .wmf.
 You first add your images to the project’s resources; then
you can assign the resource to the Image property of a
PictureBox control.
Picture Boxes properties
Picture Boxes manipulation
Assigning an Image to a Picture Box by C# code

Clearing a Picture Box by C# Code


ToolTips
 If you are a Windows user, you probably
appreciate and rely on ToolTips , those small
labels that pop up when you pause your mouse
pointer over a toolbar button or control.
 You can easily add ToolTips to your projects by
adding a ToolTip component to a form.
ToolTips
Naming controls
Setting Visibility at Run Time
 You may want the visibility of a control to depend
on the selection a user makes in a check box or
radio button.
Disabling Controls
 The Enabled property of a control determines
whether the control is available or “grayed out.”
 The Enabled property for controls is set to true by
default, but you can change the value at either
design time or run time.
Thank you

You might also like