A newer version of this page is available. Switch to the current version.

FilterControl.BeforeShowValueEditor Event

Fires before displaying an editor used to edit operands in the FilterControl.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v19.1.dll

Declaration

[DXCategory("Events")]
public event ShowValueEditorEventHandler BeforeShowValueEditor

Event Data

The BeforeShowValueEditor event's data class is ShowValueEditorEventArgs. The following properties provide information specific to this event:

Property Description
CurrentNode Gets the current node in the FilterControl’s tree of criteria.
CustomRepositoryItem Allows you to specify a custom editor to be opened instead of the default one, specified by the Editor property.
Editor Gets the currently processed editor. Inherited from ValueEditorEventArgs.
FocusedElementIndex Gets the index of the current operand value.
OperandValue Gets the current operand value.
Operation Gets the operation of the current node.
PropertyName Gets the name of the current property (column/field). Inherited from BaseNodeEventArgs.
PropertyType Gets the type of the current property (column/field). Inherited from BaseNodeEventArgs.

Remarks

To access the operand value currently being edited and customize the editor used to edit the value, use the parameters provided by the event.

Example

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.

FilterControl_CustomValueEditor_ex

        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;
        }

Examples

The following code shows how to handle the FilterControl.BeforeShowValueEditor event for a FilterControl being used in the Grid Control. This event fires when an editor used to edit an operand value is invoked. In the example, the editor’s foreground color is modified.

To subscribe to the FilterControl.BeforeShowValueEditor event when using the FilterControl within the Grid Control, the ColumnView.FilterEditorCreated event is handled.

using DevExpress.XtraEditors.Filtering;
using DevExpress.XtraGrid.Views.Base;

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

void FilterControl_BeforeShowValueEditor(object sender, ShowValueEditorEventArgs e) {
    // Set the foreground color to Red
    e.Editor.Properties.Appearance.ForeColor = Color.Red;
}
See Also