by Dinesh Thakur Category: Lists Loops and Printing

We can use several methods to fill a listbox & combobox. If we know the list contents at design time and list never changes , we define list item in properties window.The list property holds the list of items for a listbox or combobox. To define the List property at design time, select the control and scroll the properties window to the List property.

 

Click on the down arrow to drop down the empty list and type our first item. Then press Ctrl + Enter to move to the next list item. Continue typing items and pressing Ctrl + Enter until we r finishe. On the last list item , do not press Ctrl + Enter or we will have an extra (blank item) on the list.

 

For adding items to the list during program execution , we will use the AddItem method in an event procedure. Syntax is as follows :

Object.addItem value (index)

Ex. lstSubject.addItem “VB”

lstSubject.addItem txtSubject.text

 



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.