Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San Diego
Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Ch. 2: More Controls Introducing more controls Working with multiple controls Designing your applications for user convenience Coding for the controls Programming hints
Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Introducing More Controls Labels: lblName.Caption=txtName.Text Text boxes: txtName.Text=“French” Frames: Groups option buttons Check boxes: chkName.Value=0, 1 or 2.caption is name Option buttons: optButton.value=True or False Images
Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Tools Introduced in Chapter 2 Check box Frame Shape Image Option button Text box Line
Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Text Boxes Default property is.Text –txtLastName = “Frockmeister” sets.Text prop. Alignment property –0 (left) –1 (right) –2 (center) The Multiline property must be true, otherwise the alignment is ignored.
Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Frames Frames are containers for option buttons and check boxes Frames establish the mutually exclusive nature of buttons: Frame Option buttons
Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Check Boxes Select or deselect Yes/No options Default property is.Value Example: chkPrint.Value = 0 (no) 0 = no, 1 = yes (checked), 2=disabled check box
Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Option Buttons Used for mutually exclusive choices such as color choices or Print All, Print Selection, or Print One Page Default property is.Value (0 or 1) Names: optBlue, optFontSize Option buttons
Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Images An image holds a picture (not an OLE object) Properties: –.Picture (the file name of an image to display) –.Stretch (picture fills control) –.Visible (true/false makes it appear/disappear) Example: imgFlag.Visible = False
Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Shape Control Shape control places rectangles, squares, ovals, circles, or other shapes on a form Shape is determined by.Shape property Shape property value
Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Line Control Draw lines on a form to separate elements Name example: linLogo A Line has very few properties: –BorderStyle –BorderWidth –BorderColor
Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Working with Multiple Controls Selecting multiple controls Deselecting a group of controls Moving controls as a group Setting properties for multiple controls Aligning controls
Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Designing Your Applications for User Convenience Designing the user interface Defining keyboard access keys (Exit) Setting command button Default and Cancel properties.Default = True or False.Cancel = True or False Setting the tab order property of controls –TabStop property (.Enabled = yes) –TabIndex property (a value beginning at 0)
Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Coding for the controls Clearing text boxes and labels Resetting the focus Setting option buttons/check boxes value properties Changing the font Properties of controls Changing multiple properties of a control Continuing program lines
Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Controls' Default Properties Each control has a default property A default property is the implied property for the object if you omit it following the object: –txtAddress = "1234 Somewhere Street" –chkPrint = True –lstChoice(index) = "14"
Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Programming hints Check the tab order of an application Use the value property of a check box or option button to set other true/false properties. Ctrl-click a tool to repeatedly use tool Create an option button inside its frame Label controls are “read only” messages Text controls are input/output controls
Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Review Questions - 1 of 2 See the "notes" portion of this slide to see the review questions
Copyright© 2000 by the McGraw-Hill Companies, Inc.Irwin/McGraw-Hill Review Questions - 2 of 2 See the "notes" portion of this slide to see the review questions -END OF CHAPTER-