Page 439 - Microsoft Office Excel 2003 Programming Inside Out
P. 439

Part 5:  Manipulating Excel Objects
                                                      Creating User Forms

                             The Column property can be used to reference a particular column or row and column value.
                             If only one argument is supplied to the Column property, you can assign values to the specified
                             column in the list. Notice that the arguments are column number and row number, which is   Chapter 19
                             the reverse order of the List property.

                             The AddItem method is typically used to add a new item to the list. You may optionally specify
                             the row where the new row should be placed. (Rows are numbered starting with row 0.) The
                             RemoveItem method removes the specified row from the list. The Clear method removes all
                             items from the list.
                             The TopIndex property contains the index of the first visible row in the list. The ListIndex
                             property contains the index of the currently selected row. It might also have a value of -1,
                             meaning that no row is currently selected. The Click event is called when the user clicks the
                             control. This routine displays the currently selected item in the list when the user clicks
                             the item.

                             Private  Sub  ListBox1_Click()

                             MsgBox  ListBox1.ListIndex
                             End  Sub
                             When the MultiSelect property is set to fmMultiSelectMulti, the user may select more than
                             one item in the list by pressing the spacebar or clicking the desired item. A value of fmMulti-
                             SelectExtended allows the user to use the Shift and Ctrl keys to aid in the selection process.
                             Holding the Shift key while moving the mouse pointer adds all the items between the last
                             selected item and the item currently under the mouse pointer. The Ctrl key allows users to
                             click and select multiple nonadjacent items. However, if the user releases both the Shift and
                             Ctrl keys, clicking on a single item will clear the list and mark only the newly selected item.
                             When your program allows multiple items to be selected, you should use the Selected prop­
                             erty along with the row number to determine the status of each row. A value of True means
                             that the row is currently selected.
                             Setting the ListStyle property to fmListStylePlain means that the list of items are displayed as
                             a normal list. Selected items are highlighted by changing the item’s background color. However,
                             a value of fmListStyleOption means that option buttons (MultiSelect=False) or check boxes
                             (MultiSelect=True) will be displayed in front of each row to simplify the selection process.
                             The Text property contains the currently selected value from the list. If the list has more than
                             one column, the TextColumn property identifies which column will be saved into the Text
                             property.
                             The MatchEntry property determines how the ListBox can be searched. A value of fmMatch-
                             EntryFirstLetter means that when the user types a letter, the list is searched for the first row
                             that has a matching character in the first position. Pressing the same character again will locate
                             the second occurrence of the letter as the first character. A value of fmMatchEntryComplete
                             allows the user to select the row by typing the prefix of characters that match the desired
                             entry. A value of fmMatchEntryNone disables the match function.


                                                                                                       413
   434   435   436   437   438   439   440   441   442   443   444