New to Telerik UI for WinForms? Start a free 30-day trial
Accessing the Editors and Changing their Properties.
Updated over 6 months ago
Since the editors are created each time when the user starts edit operation, they can by accessed in the CellEditorInitialized event. The following example shows how you can access some of the editors and change their properties.
C#
void radVirtualGrid1_CellEditorInitialized(object sender, VirtualGridCellEditorInitializedEventArgs e)
{
var dateTimeEditor = e.ActiveEditor as VirtualGridDateTimeEditor;
if (dateTimeEditor != null)
{
var editorElement = dateTimeEditor.EditorElement as RadDateTimeEditorElement;
editorElement.Format = DateTimePickerFormat.Custom;
editorElement.CustomFormat = "dd/MM/yyyy";
}
var dropDownListEditor = e.ActiveEditor as VirtualGridDropDownListEditor;
if (dropDownListEditor != null)
{
RadDropDownListEditorElement element = dropDownListEditor.EditorElement as RadDropDownListEditorElement;
element.DisplayMember = "Name";
element.ValueMember = "Name";
element.DataSource = GetTable();
}
var textBoxEditor = e.ActiveEditor as VirtualGridTextBoxEditor;
if (textBoxEditor != null)
{
var editorElement = textBoxEditor.EditorElement as RadTextBoxEditorElement;
editorElement.TextBoxItem.ForeColor = Color.Red;
}
}