FlexGrid for WinForms | ComponentOne
C1.Win.FlexGrid Namespace / C1FlexGridBase Class / Editor Property
Example

In This Topic
    Editor Property (C1FlexGridBase)
    In This Topic
    Gets or sets a reference to the cell editor that is currently active.
    Syntax
    'Declaration
     
    
    Public Property Editor As Control
    public Control Editor {get; set;}
    Remarks

    The Editor property returns a reference to the cell editor that is currently active. This may be one of the built-in editors (a TextBox, a ComboBox, or a DateTimePicker control), a custom editor, or null (if the grid is not in edit mode).

    You can use this property to programmatically access the editor, or to find out if the grid is in edit mode.

    If you don't want to use the grid's built-in editors, you can use any other control instead. To do this, either associate the external editor with a specific grid row, column, or CellStyle using the CellStyle.Editor property, which you can get and set at any time.

    Alternatively, you can handle the StartEdit event and assign any control directly to the Editor property. (Note that the grid's Editor property can only be assigned while handling the StartEdit event, and is automatically reset to null when the grid exits edit mode.)

    Any control can be used as an external editor, but to achieve complete integration with the grid, the external editor should implement the C1.Win.IEmbeddedEditor interface. Some controls implement this interface natively and don't require any extra code to be used as grid editors (like the ones in the C1Input library). Most, however, will require you to implement at least a few of the methods in C1.Win.IEmbeddedEditor.

    For examples of custom editors, please see Using Custom Editors and Creating Custom Editors in this documentation, or visit our on-line sample library at https://www.grapecity.com/en/samples and download the "CustomEditors" sample.

    Example
    The code below uses the SetupEditor event to customize the current editor by setting two properties.
    void _flex_SetupEditor(object sender, C1.Win.FlexGrid.RowColEventArgs e)
    {
        TextBox tb = _flex.Editor as TextBox;
        if (tb != null)
        {
            tb.CharacterCasing = CharacterCasing.Upper;
            tb.MaxLength = 12;
        }
    }
    See Also