Lec13 - Lecture 13 More Lists and Menus PIC 10C Todd...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Lecture 13: More Lists and Menus PIC 10C Todd Wittman List Box Summary s Items is an array of objects, each represented on screen by the object's ToString() function. s We can tell which item the user clicked on using: b listBox.SelectedItem ( == null if no item selected) b listBox.SelectedIndex (== -1 if no item selected) s We can manually add and remove items with: b listBox.Items.Add ( object ) b listBox.Items.Remove ( object ) b listBox.Items.RemoveAt ( pos ) s To find out how many you have: b int x = listBox.Items.Count;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 More List Boxes s There are 5 variations on the ListBox control. b CheckedListBox (p. 250) b ComboBox (p. 251) b ListView (MSDN Notes) b TreeView (p. 253) b DataGridView (p. 372, MSDN) s The properties are very similar to the basic list box. Checked List Box s The CheckedListBox control is a list box with a check box next to each item. Double-clicking an item will check/un-check the box. s It maintains two arrays: Items and CheckedItems string names = ""; foreach (string s in checkedListBox1.CheckedItems) names += (s + " "); label1.Text = "You checked: " + names;
Background image of page 2
Combo Box s The ComboBox control is a very useful control that allows the user to select an item from a drop-down menu. s You can see which item is selected with SelectedItem or SelectedIndex. Or you can see the current string with Text. s The DropDownStyle property gives you 3 choices: b Simple -- always displays full list. User can type into box. b DropDown -- (default) user can select item from list or type something in like a text box b DropDownList -- user can only select item from list Simple DropDown DropDownList List View s The ListView control allows you to display items in a matrix fashion. s
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/18/2010 for the course PIC 10C taught by Professor Wittman during the Spring '10 term at UCLA.

Page1 / 10

Lec13 - Lecture 13 More Lists and Menus PIC 10C Todd...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online