There are two kinds of objects in the grid:
- Buttons, checkbox
- Are always visible on the grid
- ComboBox, EditFilters, DatePicker, TimePicker
- Are only visible on the grid when you enter in Edition mode by double clicking on a cell
- Editors are not saved par cell in order to use less memory so you should use the
GetEditorType event to set the editor in a cell
Buttons
Buttons can be added with:
- sprite(1).SetbuttonHere(2,2,true)
And deleted with:
- sprite(1).SetbuttonHere(2,2,false)
You can trap the event when a user click on a button with:
- on ButtonClick me, col, row
- put "Button clicked on cell ("&col&","&row&")"
- end
Checkbox
Checkbox can ba added with:
- sprite(1).SetCheckBoxHere(2,2,true)
And deleted with:
- sprite(1).SetCheckBoxHere(2,2,false)
You can set the state with:
- sprite(1).SetChecked(2,2,true)
And get the state with:
- put sprite(1).GetChecked(2,2)
ComboBox, EditFilters, DatePicker, TimePicker
We don't associate an editor to a cell in the xtra to preserve the memory: for example, it's useless to see the combobox in the grid until you are in Edition mode, only the selected value is important.
So you set the editor with the
GetEditorType event which is called each time the user enter in the Edition mode in the grid:
- on GetEditorType me,
ACol, ARow
This script is a movie script, it's not a behavior on the sprite.
You can choose one value between:
- Edit = 0
- ComboEdit = 1
- ComboList = 2
- DatePicker = 3
- TimePicker = 4
- CheckBox = 5
- EditNumber = 6 -- allow characters [0-9] + the decimal character (specified in the decimalseparator property)
- EditFilter = 7 -- allow characters specified in the EditFilter property
- Button = 8
And return this value to set the Editor. For example, this code place a combobox in the cell (2,2) when the user doubleclick on this cell:
- on GetEditorType me, col, row
- if col=2 and row=2 then
- return 2 -- show ComboList on cell (2,2)
- end if
- end
In this example, the combobox is empty, you can fill it with:
- on GetEditorType me, col, row
- if col=2 and row=2 then
- sprite(1).ClearCombo()
- sprite(1).AddComboItem("Red","Green","Blue")
- return 2 -- show ComboList on cell (2,2)
- end if
- end
You can download the demo in the Download section to see this code in action.
Click here to go to the download section.
Click here to order this product.
Copyright © by cXtra - Xtra for Macromedia Director All Right Reserved.