VSFlexGrid Tutorials > Edit Demo > Step 5: Input Masks |
When picking data from a list, there's usually little need for data validation. When input values are typed in, however, you will often want to make sure it is valid.
In our example, we would like to prevent users from typing text or negative values in column 3 (Amount Sold). You can do this using the ColEditMask property, which assigns an input mask to a column that governs what the user can type into that field.
The ColEditMask 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" ' assign edit mask to column 3 (Amount Sold) fg.ColEditMask(3) = "######.##" ' 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 |
The edit mask ensures that the user will not type anything into column 3 except numbers. The syntax for the ColEditMask property allows you to specify several types of input. See the control reference for details.