chapter 3 1 controls
Download
Skip this Video
Download Presentation
Chapter 3.1 Controls

Loading in 2 Seconds...

play fullscreen
1 / 37

Chapter 3.1 Controls - PowerPoint PPT Presentation


  • 82 Views
  • Uploaded on

Chapter 3.1 Controls. Programming In Visual Basic.NET. Controls in the Toolbox. Those controls that we will use in this class. The Name Property. How the programmer refers to a control in code Name must begin with a letter Must be less than 215 characters long

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Chapter 3.1 Controls' - zephania-gentry


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
chapter 3 1 controls

Chapter 3.1Controls

Programming In

Visual Basic.NET

controls in the toolbox
Controls in the Toolbox

Those controls that we will use in this class.

the name property
The Name Property
  • How the programmer refers to a control in code
  • Name must begin with a letter
  • Must be less than 215 characters long
  • May include numbers and the underscore
  • Use appropriate 3 character naming prefix
text box txt
Text Box (txt)
  • Used for user input/data entry
  • Text Property
    • What is displayed in text box
    • What user entered in text box
  • TextAlign Property
    • Controls alignment of text in the Text Box
  • Change Event
textbox control properties
TextBox Control – Properties
  • BorderStyle - defines the border surrounding the text box
  • ForeColor,BackColor - defines the text color and background color respectively
  • Enabled - controls whether the text box can get focus and will respond to events
  • Locked - controls whether user can change the text appearing in the text box
  • MultiLine - controls whether text will appear on multiple lines
  • MaxLength - defines the maximum number of characters that the user can enter into the text box
textbox control properties1
TextBox Control – Properties
  • Name - defines name used to reference control instance with code
    • Again, use a standard prefix of "txt"
  • ScrollBars - defines whether vertical or horizontal scroll bars appear in text box
  • Text - contains the text appearing in text box
  • TextAlign - justifies text within the visible region of the control instance
  • X, Y, Height, Width properties define the position and size of the control instance
textbox methods and events
TextBox - Methods and Events
  • Focus method sets input focus to a text box
  • Enter event fires when text box gets focus
  • Leave event fires when text box loses focus
  • TextChanged event fires when the the textual contents change at run time
    • The event fires for each character typed
button btn
Button (btn)
  • Used to run/activate an Event Procedure
  • Click event
  • Properties
    • Text – Change the text property to display text to user
    • Image – change image to use a graphic button
    • Forecolor – changes the color of the text displayed
    • Backcolor – changes the color of the button
label lbl
Label (lbl)
  • Used for
    • Output on a form
    • Identification of objects
    • Directions/Information
  • Cannot by modified by user
label properties
Label Properties
  • Text – used to display text or instructions to the user
  • Font – change font size, color, appearance
  • Image – use images to draw attention
  • Autosize – adjust the label object to text entered into the text property
  • textAlign – aligns the text displayed on the object
group box grp
Group Box (grp)
  • Used as containers for other controls such as radio buttons and check boxes
  • Improves readability of form
  • Text Property
    • What is displayed on the top edge of the group box
  • Splits the form object into separate planes
    • allows several groups of radio buttons on one form.
group box grp1
Group box (grp)
  • Group boxes must be added to the form before other objects are added to them.
    • You can not drag checkboxes or radio buttons from the form to the group box
    • The group box must have the focus of the cursor before you draw your other objects inside them
      • Editing handles must be visible
check box chk
Check Box (chk)
  • Used for user input/data entry
  • Allows the user to select or deselect 1 or more in any group
  • Checked Property
    • Checked = True
    • Unchecked = False
  • CheckChanged Event – default event
radio button rdo
Radio Button (rdo)
  • Used for user input/data entry
  • Allows the user to select only 1 in any group
  • First create a group and then create each radio button inside the group
  • Checked Property
    • Checked = True
    • Unchecked = False
  • CheckChanged Event – default event
picture box pic
Picture Box (pic)
  • Displays/contains a picture/graphic
  • Image Property
    • Complete path and filename of graphic
    • .bmp, .gif (including animated), .jpg, .png, .ico, .emf, .wmf
  • SizeMode Property
    • StretchImage causes graphic to be resized to match the size of the control
  • Visible Property
other properties
Other Properties
  • BorderStyle Property –None, FixedSingle, Fixed3D
  • Forecolor – changes the color of text inside object
  • Backcolor – changes the color of object
  • Textalign – aligns text property
  • Enable
    • true (user can activate the object),
    • false (object us not available to user)
  • Visible
    • True (object appears on form)
    • False (object is hidden at run time)
  • TabIndex – set the order of the focus for controls on the form
properties and methods
Properties and Methods
  • Properties can be set at design time in the property box
  • Or they be changed during program execution by statements in your code
    • txtHours.Text = "“ ‘ clears the content
  • Methods are action performed on objects
    • txtHours.focus
selecting multiple controls
Selecting Multiple Controls
  • SHIFT-Click or CTRL-Click to select/deselect multiple controls
  • Use the mouse to drag a selection box around multiple controls
  • To deselect all selected controls click elsewhere on the form
selecting multiple controls cont
Selecting Multiple Controls (cont.)

Start

here

Drag

to here

Using mouse to drag a selection box around multiple controls

Multiple selected controls,

observe selection handles.

what can be done with multiple selected controls
What Can be Done with Multiple Selected Controls?
  • Use Format Menu or Layout Toolbar to
    • Align them to each other
    • Make same size
    • Modify the spacing between them
  • Move them as a group
  • Set their common properties
designing the user interface
Designing the User Interface
  • To the user the Interface should be
    • Easy to understand
    • Familiar
    • Comfortable
    • Organized
    • Sans Serif Fonts are best, not boldface or large
    • Color Neutral Overall
    • Keyboard Accessible
keyboard access keys

Text=&OK

Text=E&xit

Keyboard Access Keys
  • Also referred to as Hot Keys
  • Underlined Letter
  • User presses ALT + underlined letter
  • Use Windows-Standard Keys
  • Defined using Text Property
default cancel buttons
Default & Cancel Buttons
  • Default Button
    • Identified visually on Form by its darker outline
    • Responds to ENTER key
    • Form\'s AcceptButton Property
  • Cancel Button
    • Responds to ESC key
    • Form\'s CancelButton Property
focus
Focus
  • One control on a Form always has the Focus
  • Not all control types can receive the focus
  • TabStop Property (applicable only for controls that are capable of receiving the focus)
    • Designates whether a control is allowed to receive the focus; True or False
tab order
Tab Order
  • User should be able to use TAB key to move the focus through a form in an organized manner; top to bottom, left to right
  • TabIndex Property
    • Number in tab sequence
    • 0 for first control to receive the focus when the form loads
  • In form’s graphic view – Use View Menu, Tab Order to set
setting tabindex property
Setting TabIndex Property
  • View menu, TabOrder
  • Click on each control in sequence to set TabIndex property of controls automatically
form s screen location
Form\'s Screen Location
  • StartPosition Property
    • Manual
    • CenterScreen
    • WindowsDefaultLocation
    • WindowsDefaultBounds
    • CenterParent
tooltips
ToolTips
  • Small label that is displayed when user places pointer on a control and pauses
  • Usually used with Command Buttons
  • Steps for creating ToolTips
    • Add a ToolTip Control to Form
      • Appears in the Component Tray, pane at bottom of Form Designer where nondisplay controls are shown
    • Set ToolTip on ToolTip1 Property of each control to the text of tip
tooltip control
ToolTip Control

Component Tray

clearing text boxes labels

txtName.Text = ""

lblMessage.Text = ""

txtCourse.Clear( )

Clearing Text Boxes & Labels
  • Set Text Property equal to the Empty String
    • Empty String is 2 quotation marks with no space between them ("")
  • Use the Clear Method of a Text Box
resetting the focus
Resetting the Focus
  • Places the Insertion Point in a Text Box
  • Use the Focus Method

txtName.Focus( )

checked property of check boxes and radio buttons
Checked Property of Check Boxes and Radio Buttons
  • Selects/Deselects Check Box or Radio Button
  • Set Checked Property
    • True = Checked, selected
    • False = Unchecked, deselected

radRed.Checked = True

chkBold.Checked = False

vb color constants
VB Color Constants
  • ForeColor and BackColor Properties
  • Use VB Color Constants from the Color Class
  • View complete list in Help by using the keyword Color followed by a period

txtName.ForeColor = Color.AliceBlue

lblMessage.BackColor = Color.White

with and end with
With and End With
  • Change several properties at once in Code
  • Will run more efficiently

With txtName

.Visible = True

.Text ="Lynne"

. Focus( )

End With

concatenation
Concatenation
  • Think of it as "glueing" text strings together
  • Example: txtFName contains First Name txtLName contains Last Name

lblFullName.Text = txtFName.Text & " " & txtLName.Text

lblNote.Text = "Today\'s weather is " & txtWeather.Text & "."

continuing lines of code
Continuing Lines of Code
  • For long lines of code it is more readable to continue them to the next line
  • At the end of the line type Line Continuation Character, a Space followed by an Underscore

lblMessage.Text = txtFName.Text & "" & txtLName.Text & _

", welcome to Aiken Technical College. Today is " & _

txtToday.Text

ad