+ All Categories
Home > Documents > Chapter02.ppt

Chapter02.ppt

Date post: 13-Sep-2015
Category:
Upload: mohamad-tarmizy-ahmad
View: 212 times
Download: 0 times
Share this document with a friend
Popular Tags:
30
Chapter 2 More Controls Programming In Visual Basic.NET
Transcript
  • Chapter 2More ControlsProgramming InVisual Basic.NET

  • Controls in the Toolbox

  • Button (btn)(review from Ch 1)Used to run/activate an Event ProcedureClick event

  • Label (lbl) (review from Ch 1)Used forOutput on a formIdentification of objectsDirections/InformationCannot by modified by user

  • Text Box (txt)Used for user input/data entryText PropertyWhat is displayed in text boxWhat user entered in text boxTextAlign PropertyControls alignment of text in the Text BoxChange Event

  • Group Box (grp)Used as containers for other controls such as radio buttons and check boxesImproves readability of formText PropertyWhat is displayed on the top edge of the group box

  • Check Box (chk)Used for user input/data entryAllows the user to select or deselect 1 or more in any groupChecked PropertyChecked = TrueUnchecked = FalseCheckChanged Event

  • Radio Button (rad)Used for user input/data entryAllows the user to select only 1 in any groupFirst create a group and then create each radio button inside the groupChecked PropertyChecked = TrueUnchecked = FalseCheckChanged Event

  • Picture Box (pic)Displays/contains a picture/graphicImage PropertyComplete path and filename of graphic.bmp, .gif (including animated), .jpg, .png, .ico, .emf, .wmfSizeMode PropertyStretchImage causes graphic to be resized to match the size of the controlVisible Property

  • Borders and StylesBorderStyle PropertyNoneFixedSingleFixed3D

  • Drawing a LineUse Label ControlText=blankBorderStyle=NoneBackColor=desired line colorWidth and Height as desiredUse the Graphics Methods covered in Chapter 12

  • Selecting Multiple ControlsSHIFT-Click or CTRL-Click to select/deselect multiple controlsUse the mouse to drag a selection box around multiple controlsTo deselect all selected controls click elsewhere on the form

  • Selecting Multiple Controls (cont.)Multiple selected controls,observe selection handles.Using mouse to drag a selection box around multiple controlsStarthereDragto here

  • What Can be Done with Multiple Selected Controls?Use Format Menu or Layout Toolbar to Align them to each otherMake same sizeModify the spacing between themMove them as a groupSet their common properties

  • Designing the User InterfaceTo the user the Interface should beEasy to understandFamiliarComfortableOrganizedSans Serif Fonts are best, not boldface or largeColor Neutral OverallKeyboard Accessible

  • Keyboard Access KeysAlso referred to as Hot KeysUnderlined LetterUser presses ALT + underlined letterUse Windows-Standard KeysDefined using Text Property

  • Default & Cancel ButtonsDefault ButtonIdentified visually on Form by its darker outlineResponds to ENTER keyForm's AcceptButton PropertyCancel ButtonResponds to ESC keyForm's CancelButton Property

  • FocusOne control on a Form always has the FocusNot all control types can receive the focusTabStop 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 OrderUser should be able to use TAB key to move the focus through a form in an organized manner; top to bottom, left to rightTabIndex PropertyNumber in tab sequence0 for first control to receive the focus when the form loadsUse View Menu, Tab Order to set

  • Setting TabIndex PropertyView menu, TabOrderClick on each control in sequence to set TabIndex property of controls automatically

  • Form's Screen LocationStartPosition PropertyManualCenterScreenWindowsDefaultLocationWindowsDefaultBoundsCenterParent

  • ToolTipsSmall label that is displayed when user places pointer on a control and pausesUsually used with Command ButtonsSteps for creating ToolTipsAdd a ToolTip Control to FormAppears in the Component Tray, pane at bottom of Form Designer where nondisplay controls are shownSet ToolTip on ToolTip1 Property of each control to the text of tip

  • ToolTip ControlComponent Tray

  • Clearing Text Boxes & LabelsSet Text Property equal to the Empty StringEmpty String is 2 quotation marks with no space between them ("")Use the Clear Method of a Text Box

  • Resetting the FocusPlaces the Insertion Point in a Text BoxUse the Focus MethodtxtName.Focus( )

  • Checked Property of Check Boxes and Radio ButtonsSelects/Deselects Check Box or Radio ButtonSet Checked PropertyTrue = Checked, selectedFalse = Unchecked, deselectedradRed.Checked = TruechkBold.Checked = False

  • VB Color ConstantsForeColor and BackColor PropertiesUse VB Color Constants from the Color ClassView complete list in Help by using the keyword Color followed by a periodtxtName.ForeColor = Color.AliceBluelblMessage.BackColor = Color.White

  • With and End WithChange several properties at once in CodeWill run more efficientlyWith txtName.Visible = True.Text ="Lynne". Focus( )End With

  • ConcatenationThink of it as "glueing" text strings togetherExample: txtFName contains First Name txtLName contains Last NamelblFullName.Text = txtFName.Text & " " & txtLName.TextlblNote.Text = "Today's weather is " & txtWeather.Text & "."

  • Continuing Lines of CodeFor long lines of code it is more readable to continue them to the next lineAt 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

    567710911141517181920212223242526


Recommended