TcxCustomGridTableView.OnInitEdit Event
Allows you to configure an in-place cell editor before it is displayed.
#Declaration
property OnInitEdit: TcxGridInitEditEvent read; write;
#Remarks
You can handle the OnInitEdit
event to customize different in-place editor settings depending on the editor type, the target cell position and value, or any other condition in your application. If you need to initialize an in-place editor with a specific value on activation, handle the OnInitEditValue event.
#Event Occurrence
The OnInitEdit
event occurs every time an in-place cell editor is about to activate; immediately after the OnEditing event.
#Event Parameters
The following parameters are available within an OnInitEdit
event handler:
Sender
- Provides access to the grid Table View that raised the in-place editor activation event.
AItem
- Provides access to the grid data item whose in-place editor is about to activate.
AEdit
- Allows you to configure the invoked in-place editor. All editor setting changes are in effect only while the in-place editor is active.
Refer to the TcxGridInitEditEvent procedural type description for detailed information on parameters accessible within an OnInitEdit
event handler.
#Code Examples
#Disable the Mouse Wheel for an In-Place Editor
The following code example disables the mouse wheel scroll functionality for the lookup combo box used as an in-place cell editor:
procedure TMyForm.cxGridTableView1InitEdit(Sender: TcxCustomGridTableView;
AItem: TcxCustomGridTableItem; AEdit: TcxCustomEdit);
var
AExtLookupComboBox: TcxExtLookupComboBox;
begin
if AEdit is TcxExtLookupComboBox then // Checks if an in-place cell editor is a lookup combo box
begin
AExtLookupComboBox := AEdit as TcxExtLookupComboBox;
AExtLookupComboBox.Properties.UseMouseWheel := False; // Disables the mouse wheel for the in-place editor
end;
end;
Tip
This scenario can be also useful for a Tcx
#Display the Drop-Down Editor Window on Activation
The following code example automatically displays the drop-down window of any TcxCustomDropDownEdit descendant used as an in-place editor every time a user invokes the editor:
procedure TMyForm.cxGridTableView1InitEdit(Sender: TcxCustomGridTableView;
AItem: TcxCustomGridTableItem; AEdit: TcxCustomEdit);
var
ADropDownEdit: TcxCustomDropDownEdit;
begin
if AEdit is TcxCustomDropDownEdit then // Checks if an in-place cell editor is a drop-down editor
begin
ADropDownEdit := AEdit as TcxCustomDropDownEdit;
ADropDownEdit.DroppedDown := True; // Opens the in-place editor's drop-down window
end;
end;
#Other In-Place Editor Management Events
#Prevent In-Place Editor Activation
The OnInitEdit
event does not allow you to prevent users from activating an in-place cell editor. To accomplish this goal, handle the OnEditing event instead.
#Multiple In-Place Editors in One Table Item
You can handle a grid table item’s OnGetProperties and OnGetPropertiesForEdit events to use multiple in-place editors in the table item. The OnGetProperties event allows you to use different in-place editors for different records in the same table item while the OnGetPropertiesForEdit event allows you to change the in-place editor and its settings when a user invokes it.