VSFlexGrid Control > VSFlexGrid Properties, Events, and Methods > VSFlexGrid Properties > ColDataType Property |
Returns or sets the data type for the column.
[form!]VSFlexGrid.ColDataType(Col As Long)[ = DataTypeSettings ]
Valid settings for the ColDataType property are listed below:
Constant |
Value |
FlexDTEmpty |
0 |
FlexDTNull |
1 |
FlexDTShort |
2 |
FlexDTLong |
3 |
FlexDTSingle |
4 |
FlexDTDouble |
5 |
FlexDTCurrency |
6 |
FlexDTDate |
7 |
FlexDTString |
8 |
FlexDTDispatch |
9 |
FlexDTError |
10 |
FlexDTBoolean |
11 |
FlexDTVariant |
12 |
FlexDTUnknown |
13 |
FlexDTDecimal |
14 |
flexDTLong8 |
20 |
FlexDTStringC |
30 |
FlexDTStringW |
31 |
This property is automatically set for each column when the control is bound to a recordset, so you can determine the data type of each field. When not in bound mode, you may set this property using code.
There are two column types that receive special treatment from the control:
FlexDTDate
This setting is taken into account when sorting dates either using the Sort property or when the user clicks the ExplorerBar. If you don't set the column type to flexDTDate, the dates will be sorted as strings.
FlexDTBoolean
This setting causes the control to display check boxes instead of strings. The mapping between strings and check boxes follows the rules for Variant conversion: any non-zero value and the "True" string are displayed as checked boxes; zero values are displayed as unchecked boxes.
For example:
fg.ColDataType(1) = flexDTBoolean
fg.TextMatrix(1, 1) = 1 ' checked
fg.TextMatrix(2, 1) = True ' checked
fg.TextMatrix(3, 1) = "True" ' checked
fg.TextMatrix(4, 1) = 0 ' not checked
fg.TextMatrix(5, 1) = "False" ' not checked
fg.TextMatrix(6, 1) = "foobar" ' not checked
If you want to display custom strings for boolean values instead of check boxes, set the ColFormat property to a string containing the values you want to display for True and False values, separated by a semicolon. For example:
fg.ColDataType(2) = flexDTBoolean
fg.ColFormat(2) = "Yes;Not Available" ' or "True;False", "On;Off", "Yes;No", etc.
When setting this property, the Col parameter should be set to a value between zero and Cols - 1 to set the data type of a given column, or to -1 to set the data type of all columns.
DataTypeSettings (Enumeration)