How to: Use Custom Value Editor in FilterControl
- 2 minutes to read
In this example, custom editors are provided to edit value operands in the FilterControl.
The custom editors (SpinEdit and CalcEdit) are supplied by handling the BeforeShowValueEditor event. To supply the editors, corresponding repository items are created and assigned to the event's CustomRepositoryItem parameter.In the example, the FilterControl is used within a GridControl. To get access and subscribe to the FilterControl's BeforeShowValueEditor event, the GridView.FilterEditorCreated event is handled.
The following image shows the result.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-provide-custom-editors-to-edit-value-operands-in-the-filtercontrol-e1519
private void gridView1_FilterEditorCreated(object sender, FilterControlEventArgs e) {
e.FilterControl.BeforeShowValueEditor +=
new ShowValueEditorEventHandler(FilterControl_BeforeShowValueEditor);
}
void FilterControl_BeforeShowValueEditor(object sender, ShowValueEditorEventArgs e) {
if(e.CurrentNode.FirstOperand.PropertyName != "Payment") return;
RepositoryItemTextEdit item = null;
if(e.FocusedElementIndex == 2)
item = new RepositoryItemSpinEdit();
else
item = new RepositoryItemCalcEdit();
item.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
item.Mask.EditMask = "c";
e.CustomRepositoryItem = item;
}