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.

Slides:



Advertisements
Similar presentations
Lists, Loops, Validation, and More
Advertisements

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 5- 1 STARTING OUT WITH Visual Basic 2008 FOURTH EDITION Tony Gaddis.
Microsoft Visual Basic: Reloaded Chapter Seven More on the Repetition Structure.
Using Macros and Visual Basic for Applications (VBA) with Excel
IS 1181 IS 118 Introduction to Development Tools VB Chapter 03.
Programming Based on Events
Lab4 ListBox Control Properties, Methods and Events.
ListBoxes The list box control allows the user to view and select from multiple items in a list. CheckedListBox control extends a list box by including.
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.
Adding Controls to User Forms. Adding Controls A user form isn’t much use without some controls We’re going to add controls and write code for them Note.
Automating Tasks with Macros. Macro Essentials  A macro is a list of actions that happen when you run the macro.  Creating a Macro: − Choose Create.
Chapter 9 Macros, Navigation Forms, PivotTables, and PivotCharts
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Programming with Microsoft Visual Basic 2012 Chapter 7: Sub and Function Procedures.
BIM313 – Advanced Programming Simple Controls 1. Contents Traditional Controls – Labels, Text Boxes, Buttons, Check Boxes, List Boxes, Combo Boxes Advanced.
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.
1 Chapter 6 – Repetition 6.1 Do Loops 6.2 For...Next Loops 6.3 List Boxes and Loops.
1 Graphical User Interfaces Part 2 Outline ListBoxes and CheckedListBoxes ListBoxes CheckedListBoxes ComboBoxes.
 What are the different types of loops? ◦ Do….While  Performs statements within loop while a condition is true ◦ Do….Until  Performs statements within.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Seven More on the Repetition Structure.
6.3 List Boxes and Loops Some Properties, Methods, and Events of List Boxes List Boxes Populated with Strings List Boxes Populated with Numbers Searching.
CIS 338: VB.NET Components Dr. Ralph D. Westfall April, 2011.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
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.
ListBox, ComboBox, Menu Chapter 5.4, ComboBox Control: Properties & Methods u Combines TextBox features with a short drop- down list  cboOne.AddItem(string)
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.
© 1999, by Que Education and Training, Appendix A, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
Microsoft Access 2010 Chapter 8 Advanced Form Techniques.
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.
Chapter 7 - Lists, loops and printing w List boxes and combo boxes several types can add items at design time or during run time user select from predefined.
Dreamweaver MX. 2 Tools for Code Editing (p. 366) n An HTML editor like Dreamweaver writes most of the code you need, but at times you will need to perform.
7-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al- ajmi Chapter 3 Some Visual Basic Controls and Events Visual Basic. NET.
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.
 A ListBox control displays a list of items and allows the user to select one or more  Drag from Toolbox to create this control on a form.
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.
Iterations (aka Loops). 2 Loops Loops (iterations) are segments of code that may be executed several times. Fixed-count (definite) loops repeat a fixed.
Unit 6 Repetition Processing Instructor: Brent Presley.
Chapter 31 Fundamentals of Programming in Visual Basic (VB) Visual Basic Events Simple Statement.
Variables and Expressions Programming Right from the Start with Visual Basic.NET 1/e 7.
IMS 3253: Controls 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Check Boxes Radio Buttons Date Time Picker Masked.
Iterations (aka Loops). 2 Loops Loops (iterations) are segments of code (loop body) that may be executed several times. Fixed-count (definite) loops repeat.
Chapter 31 Fundamentals of Programming in Visual Basic (VB) Visual Basic Events Simple Statement.
COMPUTER PROGRAMMING I Apply Procedures to Develop List Box and Combo Box Objects.
A little PHP. Enter the simple HTML code seen below.
Microsoft Visual Basic 2008: Reloaded Third Edition
Apply Procedures to Develop Menus, List Box and Combo Box Objects
Computing with C# and the .NET Framework
Chapter 9 – Additional Controls and Objects
Using Procedures and Exception Handling
Apply Procedures to Develop Menus, List Box and Combo Box Objects
Chapter 6 – Repetition 6.1 Do Loops 6.2 For...Next Loops
Repeating Program Instructions
Chapter 9 – Additional Controls and Objects
Chapter 7 Advanced Form Techniques
The Check Box Control Consists of a small square and a caption
Chapter#9: A Deeper Look In Controls
Microsoft Visual Basic 2005: Reloaded Second Edition
Chapter 9 – Additional Controls and Objects
Welcome with Ifs CSC 230 (Blum).
CIS16 Application Development and Programming using Visual Basic.net
CIS16 Application Development and Programming using Visual Basic.net
Lecture Set 10 Windows Controls and Forms
Additional Topics in VB.NET
CHAPTER FOUR VARIABLES AND CONSTANTS
Presentation transcript:

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 If the Sorted property is set to True, then the following will place an item into the list in order and assign the index of its position to num: num = lstBox.Items.Add(str) Chapter 9

Useful Properties of the List Box For the total number of items in a list box: lstBox.Items.Count Note: Each item in lstBox is identified by an index number from 0 to lstBox.Items.Count - 1 For the index number of the currently highlighted item: lstBox.SelectedIndex lstBox.Items.Count-1 is the value of the last subscript (index) because the list starts at 0. If no item is highlighted, the value of SelectedIndex is –1. Chapter 9

More List Box Properties lstBox.Items() is the list of items in the list box. The value of the item with an index of n is: lstBox.Items(n) The data type of the elements in the lstBox.Items() array is Object. To put the first element of lstBox.Items in a text box: txtBox.Text = CStr(lstBox.Items(0)) Type Conversion Function Chapter 9

Type Conversion Function CStr Original Data Returns Boolean Data Type A string containing "True" or "False". Date Data Type A string containing a Date value (date and time) in the short date format of your system. Numeric Data Types A string representing the number. Chapter 9

Currently Highlighted Item in a List Boxes The currently highlighted item can be obtained as: lstBox.Items(lstBox.SelectedIndex) Or lstBox.Text Chapter 9

Removing Items from a List Box To delete an item at a given location: lstBox.Items.RemoveAt(n) To delete the first occurrence of an item: lstBox.Items.Remove(str) To remove everything from a list box: lstBox.Items.Clear() Chapter 9

List Box Events Three main types of events with list boxes: Click – if the user clicks on an item in the list box SelectedIndexChanged - if the user clicks on an item or uses the arrow keys to select it DoubleClick - if the user double-clicks on an item The Click, DoubleClick, and SelectedIndexChanged events are all triggered when the user double-clicks. Chapter 9

Lab Sheet 9.1: Form lstOxys txtSelected Chapter 9

Lab Sheet 9.1 : Code Private Sub lstOxys_SelectedIndexChanged(...) _ Handles lstOxys.SelectedIndexChanged txtSelected.Text = CStr(lstOxys.SelectedItem) End Sub Private Sub btnAdd_Click(...) Handles btnAdd.Click Dim item As String item = InputBox("Item to Add:") lstOxys.Items.Add(item) Private Sub lstOxys_DoubleClick(...) _ Handles lstOxys.DoubleClick lstOxys.Items.RemoveAt(lstOxys.SelectedIndex) txtSelected.Clear() Chapter 9

Filling a List Box at Design Time Select the Items property of the list box. Click on the ellipsis button on the right side of the Settings box. (A window titled String Collection Editor will be displayed.) Type in the first item, and press Enter. Repeat Step 3 for each of the other items. When you are finished entering items, click on the OK button. Chapter 9

The Combo Box Control A list box combined with a text box The user has the option of selecting from a list or typing in something Essentially same properties, events, and methods as list box Chapter 9

DropDown (and DropDownList) combo box The Combo Box Control Three types of combo boxes in the DropDownStyle property: DropDown (and DropDownList) combo box Simple combo box Chapter 9

Lab Sheet 9.1 txtName cboTitle txtDisplay Private Sub btnDisplay_Click(...) _ Handles btnDisplay.Click txtDisplay.Text = cboTitle.Text & " " & txtName.Text End Sub txtName cboTitle txtDisplay Chapter 9