Edit this page

Switching Editors

When edit operation is about to begin, the EditorRequired event is fired. By using this event, you can replace the default text box editor with one of the four built-in editors that RadCardView provides: ListViewTextBoxEditor, ListViewDropDownListEditor, ListViewSpinEditor, ListViewDateTimeEditor. You can also provide a custom instance as an editor. The default editor used by RadCardView is ListViewTextBoxEditor.

The following example shows how you can change the editor type:

Fig. 1: Changed Editors

cardview-editors-overview 001

Changing Editor Type

private void radCardView1_EditorRequired(object sender, Telerik.WinControls.UI.ListViewItemEditorRequiredEventArgs e)
{
    if (e.ListViewElement.CurrentColumn.FieldName == "TitleOfCourtesy")
    {
        ListViewDropDownListEditor editor = new ListViewDropDownListEditor();
        (editor.EditorElement as BaseDropDownListEditorElement).Items.Add("Ms.");
        (editor.EditorElement as BaseDropDownListEditorElement).Items.Add("Mr.");
        (editor.EditorElement as BaseDropDownListEditorElement).Items.Add("Mrs.");
        e.Editor = editor;
    }
    else if (e.ListViewElement.CurrentColumn.FieldName == "EmployeeID")
    {
        e.EditorType = typeof(ListViewSpinEditor);
    }
    else if (e.ListViewElement.CurrentColumn.FieldName == "BirthDate" || e.ListViewElement.CurrentColumn.FieldName == "HireDate")
    {
        e.EditorType = typeof(ListViewDateTimeEditor);
    }
    else
    {
        e.EditorType = typeof(ListViewTextBoxEditor);
    }
}

Private Sub radCardView1_EditorRequired(sender As Object, e As Telerik.WinControls.UI.ListViewItemEditorRequiredEventArgs)
    If e.ListViewElement.CurrentColumn.FieldName = "TitleOfCourtesy" Then
        Dim editor As New ListViewDropDownListEditor()
        TryCast(editor.EditorElement, BaseDropDownListEditorElement).Items.Add("Ms.")
        TryCast(editor.EditorElement, BaseDropDownListEditorElement).Items.Add("Mr.")
        TryCast(editor.EditorElement, BaseDropDownListEditorElement).Items.Add("Mrs.")
        e.Editor = editor
    ElseIf e.ListViewElement.CurrentColumn.FieldName = "EmployeeID" Then
        e.EditorType = GetType(ListViewSpinEditor)
    ElseIf e.ListViewElement.CurrentColumn.FieldName = "BirthDate" OrElse e.ListViewElement.CurrentColumn.FieldName = "HireDate" Then
        e.EditorType = GetType(ListViewDateTimeEditor)
    Else
        e.EditorType = GetType(ListViewTextBoxEditor)
    End If
End Sub

See Also