Column_Combo_State - DfBaseEntryList
Specifies whether a column of a grid is presented as a combo form
Type: Property
Access: Read/Write
Data Type: Boolean
Parameters: None
Parameters
| Parameter | Type | Description |
|---|---|---|
| iColumn | integer | The column number (0-based) |
Syntax
Property Boolean Column_Combo_State
| Access Type | Syntax |
|---|---|
| Read Access: | Get Column_Combo_State to BooleanVariable |
| Write Access: | Set Column_Combo_State to BooleanVariable/Value |
Description
The Column_Combo_State property specifies whether iColumn of this grid is presented as a combo form. This will be used most-often when a column's field is defined by its data dictionary as having a validation table. This property can be used with dbGrid objects.
This property is normally set once for each column that needs a combo. However, this can be set and unset on an item by item basis to allow for custom combos based on a row. This can be set/unset inside in the item_change message before the forward send. When this tecnique is used all column-combo data will need to be set on an item by item basis.
Sample
Normally this property is set once in your program when the object is being created. If a data field value can be represented as a combo form, you can set the dbGrid's column to be a combo form by setting this property to true.
Set Column_Combo_State 4 to True
Toggling Column-Based Combos Dynamically
This property may be set dynamically, although such usage would be unusual. If the property is changed when the object is active, you will not see a change in the object's appearance until you redisplay the object.
Sample
This sample would toggle a column's combo state and update the dbGrid as required.
Procedure ToggleCombo4
Boolean bState
Get Column_Combo_State 4 to bState
Set Column_Combo_State 4 to (not(bState))
// if the object is active, we must refresh to see changes
If (Active_State(Self)) send Display
End_Procedure // ToggleCombo4
Cell-Specific Combos
You can take advantage of the fact that combo forms are drawn only when the cell that has a column-based combo form is entered and turn off the column-based combo as the user moves through the table. Item_Change is an excellent place to do this.
Sample
This sample shows how to make a combo form appear for a specific cell instead of the entire column. This sample can be tested in a Grid or dbGrid with 3 columns. When the user moves to item 5 (since items are zero-based, this would be the 3rd column in the 2nd row), a combo form appears in that cell. If moving to any other cell, the combo for the target item's column is turned off.
Procedure Item_Change integer iFromItem integer iToItem returns integer
integer iRetVal iTargetColumn iTargetItem
move 5 to iTargetItem
// determine the column iTargetItem is in
move (iTargetItem / (Base_Item(Self)) + 1) to iTargetColumn
// turn on combo form for iToItem if we're in the right column
if (iToItem = iTargetItem) begin
set Column_Combo_State iTargetColumn to True
send Column_Combo_Add_Item iTargetColumn "Joan" ""
send Column_Combo_Add_Item iTargetColumn "George" ""
send Column_Combo_Add_Item iTargetColumn "Zach" ""
end
// turn the combo off for iToItem's column if it is currently on
else begin
set Column_Combo_State iTargetColumn to False
end
forward get msg_Item_Change iFromItem iToItem to iRetVal
procedure_return iRetVal
End_Procedure // Item_Change
Sample
This sample fills a grid with 20 rows of 3 columns each. It then instructs the grid to make column 2 a combo form, to sort the combo form's dropdown list, and adds 3 items to the dropdown list.
Procedure DoFillGrid
integer iRow iMaxRows iCount
string sCustomerName
move "John Q. Customer" to sCustomerName
move 20 To iMaxRows
For iRow From 1 To iMaxRows
Send Add_Item Msg_None (sCustomerName + string (iRow)))
Send Add_Item Msg_None ("305-555-1212")
Send Add_Item Msg_None (if(mod(iCount,2)=0,"Type 1","Type 2"))
increment iCount
Loop
End_Procedure // DoFillGrid
send DoFillGrid
// make column 2 a combo
set Column_Combo_State 2 to True
// sort the dropdown list for the combo in column 2
set Column_Combo_Sort_State 2 to True
// add items to the dropdown list for the combo in column 2
Send Column_Combo_Add_Item 2 "Type 3"
Send Column_Combo_Add_Item 2 "Type 2"
Send Column_Combo_Add_Item 2 "Type 1"
| Col 1 | Col 2 |
|---|---|
| Note: | Column_xxx states must be set after the Entry_Items, in order for it to take effect |
Default is false