List Box in Widget Swap Drop Down Lists in GPE Naming Convention List boxeslst (El Es Tee – not 1 s t) Drop Down Listscbo (for combo box – old name)

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.
VB List(Of type) A List can be thought of as an array that automatically adjusts its size as elements are added and removed A List may hold only objects.
Generics, Lists, Interfaces
Programming with Microsoft Visual Basic 2008 Fourth Edition
Chapter 7: Sub and Function Procedures
Microsoft Visual Basic: Reloaded Chapter Six Repeating Program Instructions.
1 Lab6 Lab6 ComboBox Control Properties, Methods and Events.
Sharing with a non U of M user: Sharing with a non U of M user: 1. From this screen, type the entire address into the yellow box.
List-based Controls. Slide 2 Introduction There are several controls that work with lists ComboBox ListBox CheckedListBox.
Cms 2 YE Closing+ tm Preparation & Closing Job Cost.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Tutorial 7: Sub and Function Procedures1 Tutorial 7 Sub and Function Procedures.
Tutorial 7: Sub and Function Procedures1 Tutorial 7 Sub and Function Procedures.
Automating Tasks with Visual Basic. Introduction  When can’t find a readymade macro action that does the job you want, you can use Visual Basic code.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
October 4, 2005ICP: Chapter 4: For Loops, Strings, and Tuples 1 Introduction to Computer Programming Chapter 4: For Loops, Strings, and Tuples Michael.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Six Repeating Program Instructions.
 What are the different types of loops? ◦ Do….While  Performs statements within loop while a condition is true ◦ Do….Until  Performs statements within.
Indexing. The Idea of Indexing Indexing means having several data items organized under a single name where the individual items can be referred to by.
110 M - 1 ListBoxes & ComboBoxes Provide a list for the user to select from Various styles, choose based on –Amount of data to be displayed –Space available.
MIS 3200 – Unit 4.2 ListItem controls – CheckBoxList – ListBox.
© 1999, by Que Education and Training, Appendix A, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 17 – Flag Quiz Application Introducing One-Dimensional.
Chapter 6: The Repetition Structure
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter Six The Do Loop and List Boxes.
Built-in Data Structures in Python An Introduction.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 24 The String Section.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Class Average Application Introducing the Do...Loop While and Do...Loop Until.
7-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Ten Structures and Sequential Access Files.
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.
MIS 3200 – Unit 5.1 Iteration (looping) – while loops – for loops Working with List Items.
Iterations (aka Loops). 2 Loops Loops (iterations) are segments of code that may be executed several times. Fixed-count (definite) loops repeat a fixed.
Visual Basic.NET BASICS Lesson 11 List Boxes, For Next Loops, and Label Settings.
List Boxes and Combo Boxes Provides a list of items to select from Various styles — choose based on Space available Need to select from an existing list.
Unit 6 Repetition Processing Instructor: Brent Presley.
Practical Programming COMP153-08S Arithmetic and Types.
Chapter 23 The String Section (String Manipulation) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Iterations (aka Loops). 2 Loops Loops (iterations) are segments of code (loop body) that may be executed several times. Fixed-count (definite) loops repeat.
21/03/ Working with Controls Text and List Boxes.
© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 9: Chapter 5: Slide 1 Unit 9 Do Until and For… Next Loops Chapter 5 Lists,
COMPUTER PROGRAMMING I Apply Procedures to Develop List Box and Combo Box Objects.
Apply Procedures to Develop Menus, List Box and Combo Box Objects
Data Validation and Protecting Workbook
Apply Procedures to Develop Menus, List Box and Combo Box Objects
GANTT CHARTS Example Example Example Example text Tasks Example 1
Repeating Program Instructions
Mon – 2Tue – 3Wed – 4Thu - 5Fri - 6Sat - 7Sun - 8 Mon – 9Tue – 10Wed – 11Thu - 12Fri – 13Sat – 14Sun -15 Mon – 16Tue – 17Wed – 18Thu - 19Fri – 20Sat –
Microsoft Visual Basic 2005: Reloaded Second Edition
MON TUE WED THU
CS 106 Computing Fundamentals II Chapter 71 “Indexing”
CIS16 Application Development and Programming using Visual Basic.net
Free PPT Diagrams : ALLPPT.com
Free PPT Diagrams : ALLPPT.com
CIS 16 Application Development Programming with Visual Basic
Lecture Set 10 Windows Controls and Forms
2008 Calendar.
Sun Mon Tue Wed Thu Fri Sat
Calendar – 2010 (October, November & December)
YOUR text YOUR text YOUR text YOUR text
Sun Mon Tue Wed Thu Fri Sat
MIS 3200 – Unit 5.1 Iteration (looping) Working with List Items
1/○~1/○ weekly schedule MON TUE WED THU FRI SAT SUN MEMO
2016 | 10 OCT SUN MON TUE WED THU FRI SAT
Sun Mon Tue Wed Thu Fri Sat
Calendar For 2019 PPT Slide JANUARY FEBRUARY MARCH APRIL MAY JUNE JULY
2008 Calendar.
CS100A Lect. 12, 8 Oct More About Arrays
Presentation transcript:

List Box in Widget Swap

Drop Down Lists in GPE

Naming Convention List boxeslst (El Es Tee – not 1 s t) Drop Down Listscbo (for combo box – old name) Orddl (whichever you use be consistent) All examples we shall relate to list boxes however the code also applies to drop down lists

Things we want to do with List Boxes Add an item to the list Set the entry so it makes sense to the user Set the entry so it makes sense to the system Remove an item from the list Read the value of the item selected by the user, i.e. find out what they clicked on Clear the list box Validate a list to make sure that an item has been selected

The Items Collection Here we can see three items listed in this lists items collection

Grouping data in Lists In computer programming there are various types of List structures that allow us to store more than one value in a singular structure. Imagine a list of Strings or Integers or even Objects. (e.g. Employees) Each item in a list has an Index. This is a numeric integer value that specifies the items position within the list. Indexing always starts at zero and ends at the lists size – 1. In a list of 5 items, the last item will have an index of 4 and the first item an index of 0.

ListBox - collection of ListItems A ListBox will contain 0, 1 or more ListItem objects. The data within a ListBox web control is stored within a List collection that is referred to by Items. (e.g. lstToDo.Items) Each ListItem has a Text and Value property. The Text is what you see on the screen and the Value is the SystemID.

Accessing a ListBox item To access an individual Item within the ListBox you will use the notation:- lstToDo.Items.Item(i) where i represents the index of the item you wish to access. For example (set and get Text and Value properties):- lstToDo.Items.Item(0).Text = Blue Widget lstToDo.Items.Item(0).Value = bluewidget.jpg Widget = lstToDo.Items.Item(2).Text WidgetImage = lstToDo.Items.Item(2).Value

Identifying What the User Selects txtSelectedItem.Text = lstToDo.SelectedValue Returns the value… Ring John

ListBox Properties lstNames.SelectedItem.TextThis allows us to obtain the text of the item in the list that has been selected by the user. lstNames.SelectedValueContains the system ID of the selected item in the list. (If you do not set this yourself it will be the same as SelectedItem.Text) lstNames.SelectedIndexThis tells us the number of the selected item in the list. (If this is -1 it means that no selection has been made.) Each item in a list box has an index. The first item has an index of zero, the second one and so on.

ListItemCollection Properties lstNames.Items.CountThe items have a count property that tells us how many items are in the list. lstNames.Items.Item(2).Text lstNames.Items.Item(4).Value Allows us to get or set the Text or system ID Value of an item in the list. Note - Items refers to the List collection contained within the List Box - Item(i) refers to the list item at index i, where i is an integer within the range of the list (0.. n-1) where n represents the number of items in the list.

ListItemCollection Methods lstNames.Items.Add(MyName) This method allows us to add an item to a list box. lstNames.Items.RemoveAt(3) Allows us to remove an item from a list box. lstNames.Items.Clear() Clears the items collection of all entries.

Adding Items to a List Box In the following example we will type two values. Breakfastthis is the value that will appear to the user athis is the identifier for this entry

Once the Item is Added…

Add Some More Items… Lunchb Supperc

Adding Items

Setting the Items Value Two things to consider… The text (that the user sees) The value (that the system uses) If we have a list with three items it has the following properties... Index Items.Count = 3Breakfast0 Lunch1 Supper2

Consider the Following Code…

Identifying what the User Selects The SelectedValue property contains the identifier of the item (the value) that the user has selected If we do not explicitly set the value of an item ourselves, the SelectedValue contains the text of the entry in the list

Deleting Items on the List

Ensuring that a User has Selected an Item

Clearing the List Box Should you wish to clear the entire contents of the list box, you would use the Clear method For example, the following code would clear a list box called lstListExample lstListExample.Items.Clear

Questions 1. Write a section of code that adds the days of the week to the list box lstDays. (Sun, Mon, Tue, Wed, Thu, Fri, Sat) 2. Write a line of code that removes Wed from the list box. 3. Write a section of code that validates if an item has been selected in the list box lstRoomForBooking