List Boxes


Methods: 


Properties:


Populating a List Box at Design Time:

To populate a list box at design time, select the list box by clicking on it, then select the List property in the Properties window.  Click the down arrow, and begin typing the list items, ending each line with a Ctrl-Enter.  When you have completed your entries simply hit the Enter key. 


 

Tricks

To force the list box to display (move focus to) the most recent addition to the list box:

lstBox.ListIndex = lstBox.NewIndex

 

To synchronize two list boxes in order to display related elements (such as student name in one box and grade in another):

Private Sub lstBox1_Scroll( )
       lstBox2.TopIndex = lstBox1.TopIndex
End Sub 

Private Sub lstBox2_Scroll( )
       lstBox1.TopIndex = lstBox2.TopIndex
End Sub