Chapter#9: A Deeper Look In Controls

Slides:



Advertisements
Similar presentations
CS0004: Introduction to Programming Select Case Statements and Selection Input.
Advertisements

Microsoft Visual Basic: Reloaded Chapter Seven More on the Repetition Structure.
C# Programming: From Problem Analysis to Program Design1 9 Programming Based on Events.
C# Programming: From Problem Analysis to Program Design1 Programming Based on Events C# Programming: From Problem Analysis to Program Design 3 rd Edition.
GUI-Labels, TextBoxes and Buttons Label- displays read-only text Common properties:  Font – font used by the text of label  Text – text to appear on.
Compunet Corporation Programming with Visual Studio.NET GUI Week 13 Tariq Aziz and Kevin Jones.
Group Boxes and Panels Arrange components on a GUI Buttons and etc. can be placed inside a group box or panel. All these buttons move together when the.
To type the VB code behind the command button (named cmdPush), Double-Click on the Push Me (caption) command button As a result the Visual Basic Code Window.
CA 121 Intro to Programming Tariq Aziz and Kevin Jones GUI Programming in Visual Studio.NET Chapter 3 Tariq Aziz and Kevin Jones.
Compunet Corporation Programming with Visual Basic.NET GUI Chapter 3 Week 13 Tariq Aziz and Kevin Jones.
110-C1 Chapter 2 of the text: _ text boxes, group boxes, check boxes, radio buttons, picture boxes _ defining access keys tab sequence setting the focus.
Chapter 2 –Visual Basic, Controls, and Events
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
Visual Basic 2008 Express Edition The IDE. Visual Basic 2008 Express The Start Page Recent Projects Open an existing project Create a New Project.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Chapter 9 - VB 2008 by Schneider1 Chapter 9 – Additional Controls and Objects 9.1 List Boxes, Combo Boxes, and the File-Opening Control 9.2 Seven Elementary.
1 Chapter 9 – Additional Controls and Objects 9.1 List Boxes and Combo Boxes 9.2 Eight Additional Controls and Objects 9.3 Multiple-Form Objects 9.4 Graphics.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Assignment #1 Advanced Computer Programming.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 4 I Need a Tour Guide.
Chapter 8: Writing Graphical User Interfaces Visual Basic.NET Programming: From Problem Analysis to Program Design.
1 CC111 Lec9 : Visual Basic Visual Basic (3) Lecture 9.
VB Procedures. Procedures. Sub procedure: Private/Public Sub SubName(Arguments) … End Sub Private: Can only be accessed by procedures in the same form.
Chapter 9 - VB.Net by Schneider1 Chapter 9 – Additional Controls and Objects 9.1 List Boxes, Combo Boxes, and the File-Opening Control The List Box Control.
1 Chapter 9 – Additional Controls and Objects 9.1 List Boxes and Combo Boxes 9.2 Eight Additional Controls and Objects 9.3 Multiple-Form Programs 9.4 Graphics.
CS0004: Introduction to Programming Project 1 – Lessons Learned.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Visual Basic Programming Introduction VB is one of the High level language VB has evolved from the BASIC language. BASIC stands for Beginners All-purpose.
CS 101 Test 2 Study Guide Acronyms RAD - Rapid Application Development IDE - Integrated Development Environment GUI - Graphical User Interface VB - Visual.
COMPUTER PROGRAMMING I 3.02 Apply Properties Associated with the Controls.
Pay Example (PFirst98) Please use speaker notes for additional information!
Created by Alia Al-Abdulkarim 2008 Visual Basic Vs. Java.
1 Chapter 4 – Decisions 4.1 Relational and Logical Operators (see other set of slides) 4.2 If Blocks (see other set of slides) 4.3 Select Case Blocks (see.
AdditionalControls 1. The MenuStrip 2 Double-click Let’s begin to design the menu bar for VB! Let’s begin to design the menu bar for VB! 3.
1 Chapter 4 – Decisions 4.1 Relational and Logical Operators 4.2 If Blocks 4.3 Select Case Blocks 4.4 Input via User Selection.
Creating Menus Menu Bar – behaves like standard Windows menus Can be used in place of or in addition to buttons to execute a procedure Menu items are controls.
Chapter 2 More Controls Programming in C#. NET Objectives Use text boxes, group boxes, check boxes, radio buttons, and picture boxes effectively.
Slide 1 Controls v Control naming convention –Label: lblName –Command Button: cmdName –Text Box: txtName.
Knowledge Base. Defining a Variable Dim statement Dim intXX As Integer Public in a Module Public dblNN As Double.
Computer Science Up Down Controls, Decisions and Random Numbers.
COMPUTER PROGRAMMING I Apply Procedures to Develop List Box and Combo Box Objects.
3.02 APPLY PROPERTIES ASSOCIATED WITH THE CONTROLS Computer Programming I.
Visual Basic Fundamental Concepts
Apply Procedures to Develop Menus, List Box and Combo Box Objects
Computing with C# and the .NET Framework
Chapter 8: Writing Graphical User Interfaces
GUI Programming using Windows Form
Chapter 9 – Additional Controls and Objects
Using Procedures and Exception Handling
Apply Procedures to Develop Menus, List Box and Combo Box Objects
Chapter 9 – Additional Controls and Objects
Chapter 4 – Decisions 4.1 Relational and Logical Operators
The Check Box Control Consists of a small square and a caption
Visual Basic..
Programming Based on Events
Chapter 9 – Additional Controls and Objects
The List Box Control Items can be placed into the list at design time or run time The Sorted property causes items in the list to be sorted automatically.
CIS16 Application Development and Programming using Visual Basic.net
Visual programming Chapter 2: Events and Event Handling
Web Development Using ASP .NET
Visual C# - GUI and controls - 1
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
GUI Programming in Visual Studio .NET
CHAPTER FOUR VARIABLES AND CONSTANTS
Presentation transcript:

Chapter#9: A Deeper Look In Controls Groupboxes , Checkboxes, tooltips , listboxex, comoboBoxes

Outlines Using Groupboxes and Panels Using a List Box for Input Using Combo box for Input Using Radio Buttons for Input Using Check Boxes for Input Events Raised by Selections

1. GroupBoxes and Panels They’re typically used to group several controls that are related in a GUI. All of the controls that you drag onto a GroupBox or a Panel move together when you move the GroupBox or Panel to a new position the Form in Design view. To attach controls to a group box, create the group box and then place the controls into the group box.

GroupBoxes and Panels GroupBoxes Panels Can display a text caption Cannot have scrollbars Example: Cannot have a text caption Can display scrollbars Example: Text Caption

Groupboxes Changing the caption text of a group box

Example #1: Groupboxes This program will display in a label box the Text name of the pressed button in a Groupbox (Groupbox1) Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click, Button4.Click Label1.Text = "You pressed " & CType(sender, Button).Text End Sub

Example#1: Output

Panels To enable the scrollbars, set the Panel’s AutoScroll property to True. Scrollbar

 Panels When you click one of these Buttons, the event handler (lines 5–11) changes the Text on the outputLabel to "You pressed: " followed by the Text of the clicked Button.

Example#2: Panels

Example2: Output

The Three Types of Controls Used for Selection list box radio buttons check boxes

click here to invoke string collection editor 2. List Boxes Fill a List Box at Design Time via its String Collection Editor Tasks button click here to invoke string collection editor

String Collection Editor Fill by direct typing or by copying and pasting from a text editor or a spreadsheet.

List Box at Run Time lstMonths selected item The value of the list box (lstMonths) is the string consisting of the selected item.

Example #3: Code for btnDetermine.Click Dim daysInMonth As String Select Case lstMonths.Text Case "September", "April", "June", "November" daysInMonth = "30" Case "February" daysInMonth = "28 or 29" Case Else daysInMonth = "31" End Select txtDays.Text = daysInMonth

3. The Combo Box Control A list box combined with a text box The user has the option of filling the text box by selecting from a list or typing directly into the list box. Essentially same properties, events, and methods as a list box DropDownStyle property specifies one of three styles

Combo Box Styles

Styles at Run Time after Arrows are Clicked The value of comboBox.Text is the contents of the text box at the top of the combo box.

Example#4 txtName cboTitle cboTitle txtDisplay Private Sub btnDisplay_Click(...) _ Handles btnDisplay.Click txtDisplay.Text = cboTitle.Text & " " & txtName.Text End Sub txtName cboTitle cboTitle txtDisplay

4. Radio Button Properties To determine if the button is selected or not If (radButton.Checked = true)Then Statement... End If has value True if button is on. To turn a radio button on radButton.Checked = True radButton.Checked = False radButton.Checked = True

Example#5: Form radChild radMinor radAdult radSenior

Example 5: Code for Button If radChild.Checked Then txtFee.Text = FormatCurrency(0) ElseIf radMinor.Checked Then txtFee.Text = FormatCurrency(5) ElseIf radAdult.Checked Then txtFee.Text = FormatCurrency(10) ElseIf radSenior.Checked Then txtFee.Text = FormatCurrency(7.5) Else MessageBox.Show("Must make a selection.") End If

Example#5: Output Note: FormatCurrency() is a built-In function that displays the dollar sign ($) in the output

5. The Check Box Control Consists of a small square and a caption Presents the user with a Yes/No choice During run time, clicking on the check box toggles the appearance of a check mark. Checked property has value True when check box is checked and False when not CheckedChanged event is raised when the user clicks on the check box

Example 6: Form chkDrug chkDental chkVision chkMedical

Example#6: Code for Button Important Note: We used here simple If...Then...EndIf statement to check the selection of the checkboxes instead of using If....Then...Else...EndIf The reason: when we find one checkbox is selected we can continue checking the other checkboxes if they were selected or not Dim sum As Double = 0 If chkDrugs.Checked Then sum += 39.15 End If If chkDental.Checked Then sum += 10.81 If chkVision.Checked Then sum += 2.25 If chkMedical.Checked Then sum += 55.52 txtTotal.Text = FormatCurrency(sum)

Example #6: Output

Events Raised by a Selection SelectedIndexChanged – raised when a new item of a list box is selected CheckedChanged - raised when the user clicks on an unchecked radio button or a check box; that is, when the value of the Checked property is changed.

Example #7: Code Private Sub checkBox_Changed(...) Handles _ chkDrugs.CheckedChanged, chkDental.CheckedChanged, chkVision.CheckedChanged, chkMedical.CheckChanged Dim sum As Double = 0 If chkDrugs.Checked Then sum += 39.15 End If (continued on next slide)

Example #7: Code (continued) If chkDental.Checked Then sum += 10.81 End If If chkVision.Checked Then sum += 2.25 If chkMedical.Checked Then sum += 55.52 txtTotal.Text = FormatCurrency(sum) End Sub

Example #7: Output

7. The ToolTip Control Appears in component tray of form with default name ToolTip1 Allows a tooltip to appear when user hovers over a control (such as a text box) Text displayed in tooltip is the setting of the “ToolTip on ToolTip1” property of the control to be hovered over

Example #8 : Form txtRate “ToolTip on ToolTip1” property of txtRate has the setting “Such as 5, 5.25, 5.5 …”

Example #8: Output