vcl-cxgridcustomtableview-dot-tcxcustomgridtableitem-59f47b10.md
Allows you to change the active in-place editor and customize its settings depending on specific conditions.
property OnGetProperties: TcxGridGetPropertiesEvent read; write;
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.
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.
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.
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;
const
SkillCount = 6;
void __fastcall TColumnsMultiEditorsDemoMainForm::clnGradeGetProperties(
TcxCustomGridTableItem *Sender, TcxCustomGridRecord *ARecord,
TcxCustomEditProperties *&AProperties) {
switch(ARecord->RecordIndex % SkillCount) {
case 0: // Assigns a spin editor to column cells in records with the following indexes: 0, 6, 12, etc.
AProperties = SpinRepositoryItemYears->Properties;
break;
case 1, 2: // Assigns an image combo box to cells in records with the following indexes: 1, 2, 7, 8, etc.
AProperties = ImageComboRepositoryItemLanguages->Properties;
break;
case 3: // Assigns an image combo box to cells in records with the following indexes: 3, 9, 15, etc.
AProperties = ImageComboRepositoryItemCommunication->Properties;
break;
case 4: // Assigns a date editor to column cells in records with the following indexes: 5, 11, 17, etc.
AProperties = DateRepositoryItemStartWorkFrom->Properties;
break;
// Column cells use the default text editor in records with the following indexes: 5, 11, 17, etc.
}
}
Tip
To see this technique in action, open the ColumnsMultiEditorsDemo project shipped with the ExpressQuantumGrid Suite.
Do not perform the following operations within OnGetProperties and OnGetPropertiesForEdit event handlers to avoid possible drawing errors and access violations:
AProperties parameter.Tip
To change the active in-place editor type or its settings within an OnGetProperties event handler in a safe manner, assign the Properties property value of an edit repository item to the AProperties parameter as demonstrated in the OnGetProperties event handler example.
See Also
TcxPivotGridField.OnGetProperties Event
TcxTreeListColumn.OnGetEditProperties Event
TcxCustomEditorRowProperties.OnGetEditProperties Event