ComponentOne VSFlexGrid 8.0
Step 4: Drop-Down Lists

Entering data is a tedious and error-prone process. Drop-down lists are great because they minimize the amount of typing you must do, reduce the chance of errors, and increase the consistency of the data.

Let's assume that our sample project only involves sales of three products (Applets, Widgets, and Gadgets), in four regions (North, South, East, and West), and that there are three full-time sales people (Mary, Sarah, and Paula).

Typing repetitive data would be inefficient and error-prone. A much better approach would be to use drop-down lists to let users pick the appropriate entry from lists. The VSFlexGrid allows you to assign a list of choices to each column using the ColComboList property. The list consists of a string with choices, separated by pipe characters ("|").

The ColComboList property must be assigned at runtime. Change the Form_Load routine as shown below:

Example Title
Copy Code
    Private Sub Form_Load()

   

        ' format column 3 (Amount Sold) to display currency

        fg.ColFormat(3) = "$#,###.00"

   

        ' make column 4 (Bonus) a boolean column

        fg.ColDataType(4) = flexdtBoolean

   

        ' assign combo lists to each column

        fg.ColComboList(0) = "Applets|Wahoos|Gadgets"

        fg.ColComboList(1) = "North|South|East|West"

        fg.ColComboList(2) = "|Mary|Paula|Sarah"

   

    End Sub

Notice how the last ColComboList string starts with a pipe. This will allow users to type additional names that are not on the list. In other words, these values will be edited using a drop-down combo, as opposed to a drop-down list as the others. There are syntax options to create multi-column lists and translated lists as well. See the control reference for more details.

Press F5 to run the project again, then move the cursor around. When you move the cursor to one of the columns that have combo lists, a drop-down button becomes visible. You may click on it to show the list, or simply type the first letter of an entry to highlight it on the list.

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback