Never did this before, but I need to make a custom change to a control that will affect all instances of it throughout the application. If the user clicks in a masked edit control at any position and the control is empty, the cursor should jump to position 1. It works fine when I use the event handler of the control directly like this:
private void mtbHomePhone_Click(object sender, EventArgs e)
{
if (mtbHomePhone.Value?.ToString()?.Length == 0)
{
mtbHomePhone.SelectionStart = 1;
mtbHomePhone.SelectionLength = 0;
}
}
I'm trying to inherit from the control like this (using MyMaskedEdit in the designer.cs in place of RadMaskedEditBox) but the event is not firing. What am I doing wrong?
using Telerik.WinControls.UI;
namespace VisionUI.Common
{
public class MyMaskedEdit : RadMaskedEditBox
{
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
if (this.Value?.ToString()?.Length == 0)
{
this.SelectionStart = 1;
this.SelectionLength = 0;
}
}
}
}
Thanks
Carl