19.12.2012 Views

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

10.1 LIST BOXES AND COMBO BOXES<br />

The dialog box in Figure 10-1 contains two list boxes, one text box, <strong>and</strong> two combo boxes. The<br />

Folders list box displays a list of folders (also known as directories). You click on a folder to highlight<br />

it <strong>and</strong> double-click on a folder to open it. A combo box combines the features of a text box <strong>and</strong><br />

a list box. With the two combo boxes (known as dropdown combo boxes), only the text box part is<br />

showing. The associated list drops down when you click on the arrow to the right of the text box part.<br />

FIGURE 10-1 Open Project Dialog Box<br />

THE LIST BOX CONTROL<br />

The fifth row of the st<strong>and</strong>ard toolbox (in most editions of <strong>Visual</strong> <strong>Basic</strong>) contains the combo box icon<br />

on the left <strong>and</strong> the list box icon on the right. The list boxes discussed in this text will display a single<br />

column of strings, referred to as items. The items to appear initially can either be specified at<br />

design time with the List property or set with code in a procedure. Then code is used to access, add,<br />

or delete items from the list. We will first carry out all tasks with code <strong>and</strong> then show how the initial<br />

items can be specified at design time. The st<strong>and</strong>ard prefix for the name of a list box is lst.<br />

The Sorted property is perhaps the most interesting list box property. When it is set to<br />

True, the items will automatically be displayed in alphabetical (that is, ANSI) order. The<br />

default value of the Sorted property is False.<br />

If str is a string, then the statement<br />

lstBox.AddItem str<br />

287

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!