TcxCustomGridTableItem.OnGetProperties Event
Allows you to change the active in-place editor and customize its settings depending on specific conditions.
#Declaration
property OnGetProperties: TcxGridGetPropertiesEvent read; write;
#Remarks
You can handle OnGetProperties
and OnGetPropertiesForEdit events to use multiple in-place editors in one table item. The OnGetProperties
event allows you to use different in-place editors for different cells in a table item while the OnGetPropertiesForEdit event allows you to change the active in-place editor and its settings when a user invokes it.
#Event Occurrence
The OnGetProperties
event occurs every time the parent grid View determines the required in-place editor and its settings for the table item, for example, when displayed data changes.
#Event Parameters
You can use Sender
and ARecord
parameters to identify the data cell whose in-place editor the parent grid View is about to determine. The AProperties
parameter allows you to use a preconfigured edit repository item to change the active in-place editor or its settings for the currently processed cell.
Refer to the TcxGridGetPropertiesEvent procedural type description for detailed information on parameters accessible within OnGetProperties
and OnGetPropertiesForEdit event handlers.
#Code Example: Multiple Editors in a Column
The following code example handles the OnGetProperties
event and uses four preconfigured edit repository items to display different in-place editors for data cells that have different roles in a column. The OnGetProperties
event handler example determines required editor types and settings by record indexes.
const
SkillCount = 6;
procedure TColumnsMultiEditorsDemoMainForm.clnGradeGetProperties(
Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
var AProperties: TcxCustomEditProperties);
begin
case ARecord.RecordIndex mod SkillCount of
// Assigns a spin editor to column cells in records with the following indexes: 0, 6, 12, etc.
0: AProperties := SpinRepositoryItemYears.Properties;
// Assigns an image combo box to column cells in records with the following indexes: 1, 2, 7, 8, etc.
1, 2: AProperties := ImageComboRepositoryItemLanguages.Properties;
// Assigns an image combo box to column cells in records with the following indexes: 3, 9, 15, etc.
3: AProperties := ImageComboRepositoryItemCommunication.Properties;
// Assigns a date editor to column cells in records with the following indexes: 4, 10, 16, etc.
4: AProperties := DateRepositoryItemStartWorkFrom.Properties;
// Column cells use the default text editor in records with the following indexes: 5, 11, 17, etc.
end;
end;
Tip
To see this technique in action, open the Columns
#Important Limitations
Do not perform the following operations within OnGetProperties
and OnGetPropertiesForEdit event handlers to avoid possible drawing errors and access violations:
- Do not change Properties, PropertiesClass, and PropertiesClassName property values.
- Do not change individual in-place editor settings accessible through the
AProperties
parameter.
Tip
To change the active in-place editor type or its settings within an On
event handler in a safe manner, assign the Properties property value of an edit repository item to the AProperties
parameter as demonstrated in the On
event handler example.