Consider the Salary field in the Employee class. A common requirement would be to change the default spin editor with a RadMaskedEditBox in the EditorInitializing event. However, if you follow the steps described here: https://docs.telerik.com/devtools/winforms/controls/datalayout/change-the-editor-to-a-bound-raddropdownlist
the BindingCreating event wouldn't be fired for any editor that is not some of the default ones.
Hello, Matthew,
The possible solution that I can suggest is to add the binding programmatically:
public RadForm1()
{
InitializeComponent();
this.radDataLayout1.EditorInitializing += radDataLayout1_EditorInitializing;
this.radDataLayout1.DataSource = new Employee()
{
FirstName = "Sarah",
LastName = "Blake",
Occupation = "Supplied Manager",
StartingDate = new DateTime(2005, 04, 12),
IsMarried = true,
Salary = 3500,
Gender = Gender.Female
};
}
RadMaskedEditBox radMaskedEditBox;
void radDataLayout1_EditorInitializing(object sender, Telerik.WinControls.UI.EditorInitializingEventArgs e)
{
if (e.Property.Name == "Salary")
{
radMaskedEditBox = new RadMaskedEditBox();
radMaskedEditBox.DataBindings.Add(new Binding("Value", this.radDataLayout1.DataSource, "Salary",
true, DataSourceUpdateMode.OnPropertyChanged));
radMaskedEditBox.MaskType = MaskType.Numeric;
radMaskedEditBox.MaskedEditBoxElement.StretchVertically = true;
e.Editor = radMaskedEditBox;
}
}
private class Employee
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Occupation { get; set; }
public DateTime StartingDate { get; set; }
public bool IsMarried { get; set; }
public int Salary { get; set; }
public Gender Gender { get; set; }
}
private enum Gender
{
Female,
Male
}
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.