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.


View Example

        private void gridView1_FilterEditorCreated(object sender, FilterControlEventArgs e) {
            e.FilterControl.BeforeShowValueEditor += 
new ShowValueEditorEventHandler(FilterControl_BeforeShowValueEditor);

        RepositoryItemSpinEdit reSpinEdit = new RepositoryItemSpinEdit();
        RepositoryItemCalcEdit reCalcEdit = new RepositoryItemCalcEdit();
        void FilterControl_BeforeShowValueEditor(object sender, ShowValueEditorEventArgs e) {
            if(e.CurrentNode.FirstOperand.PropertyName != "Payment") return;
            RepositoryItemTextEdit item = null;
            if(e.FocusedElementIndex == 2)
                item = reSpinEdit;
                item = reCalcEdit;
            item.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
            item.Mask.EditMask = "c";
            e.CustomRepositoryItem = item;