I have some data driven edit fields that I need to edit based on the ControlType enum value in the event handler shown below. Mostly its working, but i have a few questions:
1. Note the commented code in DateEntry. I'd like to customize the date editor as I'm doing this using a DateTimePicker elsewhere in the application. How can I access the properties show in this code?
2. Is there an equivalent of a CheckBox or will I need to use a Yes/no combo box?
Thanks
Carl
void gvDataDriven_EditorRequired(object sender, EditorRequiredEventArgs e)
{
int dataDrivenSetupID = int.Parse(gvDataDriven.CurrentRow.Cells["DataDrivenSetupID"].Value.ToString());
DataDrivenSetup dataDrivenSetup = dataDrivenSetupList.Where(n => n.DataDrivenSetupID == dataDrivenSetupID).FirstOrDefault();
switch ((ControlType)dataDrivenSetup.ControlID)
{
case ControlType.TextBox:
VirtualGridTextBoxEditor virtualGridTextBoxEditor = new VirtualGridTextBoxEditor();
virtualGridTextBoxEditor.MaxLength = dataDrivenSetup.MaxLength.Value;
e.Editor = virtualGridTextBoxEditor;
break;
case ControlType.NumericEntry:
VirtualGridMaskedEditBoxEditor virtualGridMaskedEditBoxEditor = new VirtualGridMaskedEditBoxEditor();
virtualGridMaskedEditBoxEditor.MaskTextBox.MaskType = MaskType.Standard;
virtualGridMaskedEditBoxEditor.MaskTextBox.Mask = "000000.00";
virtualGridMaskedEditBoxEditor.MaskTextBox.TextAlign = HorizontalAlignment.Right;
virtualGridMaskedEditBoxEditor.MaskTextBox.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
e.Editor = virtualGridMaskedEditBoxEditor;
break;
case ControlType.DateEntry:
VirtualGridDateTimeEditor virtualGridDateTimeEditor = new VirtualGridDateTimeEditor();
//virtualGridDateTimeEditor.NullText = "MM/DD/YYYY";
//virtualGridDateTimeEditor.NullableValue = null;
//virtualGridDateTimeEditor.SetToNullValue();
//virtualGridDateTimeEditor.Format = DateTimePickerFormat.Short;
//virtualGridDateTimeEditor.DateTimePickerElement.TextBoxElement.MaskType = MaskType.FreeFormDateTime;
e.Editor = virtualGridDateTimeEditor;
break;
case ControlType.CheckBox:
break;
case ControlType.ComboBox:
VirtualGridDropDownListEditor dropDownListEditor = new VirtualGridDropDownListEditor();
RadDropDownListEditorElement element = dropDownListEditor.EditorElement as RadDropDownListEditorElement;
List<Dictionary> data = CommonServices.GetDictionary((EDictionaryType)dataDrivenSetup.DictionaryTypeID, 1, true);
element.DataSource = data;
element.ValueMember = "DictionaryID";
element.DisplayMember = "Description";
element.DropDownStyle = RadDropDownStyle.DropDownList;
e.Editor = dropDownListEditor;
break;
}
}