In scenarios, where you don't want to display the deafult value for a text box, when an empty string is entered, you will need to show the NullText. To show
null text in RadMaskedEditBox you have to set its Text property to an empty string and move the focus to another control on the form as in the
following example:
| [C#] Set NullText on empty value |
Copy Code |
|
private void Form1_Load(object sender, EventArgs e)
{
this.radMaskedEditBox1.Mask = "0000000";
this.radMaskedEditBox1.MaskType = Telerik.WinControls.UI.MaskType.Standard;
this.radMaskedEditBox1.NullText = "Please enter a
digit";
this.radMaskedEditBox1.PlaceHolder = '_';
this.radMaskedEditBox1.Text = string.Empty;
this.SelectNextControl(this.radMaskedEditBox1, true, false, false, true);
this.radMaskedEditBox1.TextChanged += new
EventHandler(radMaskedEditBox1_TextChanged);
}
void radMaskedEditBox1_TextChanged(object sender, EventArgs e)
{
if (this.radMaskedEditBox1.Value.ToString() == string.Empty)
{
this.radMaskedEditBox1.Text = string.Empty;
}
}
|
| [VB] Set NullText on empty value |
Copy Code |
|
Private Sub Form1_Load(ByVal sender As
Object, ByVal e As EventArgs)
Me.radMaskedEditBox1.Mask = "0000000"
Me.radMaskedEditBox1.MaskType = Telerik.WinControls.UI.MaskType.Standard
Me.radMaskedEditBox1.NullText = "Please enter a digit"
Me.radMaskedEditBox1.PlaceHolder = Microsoft.VisualBasic.ChrW(95)
Me.radMaskedEditBox1.Text = string.Empty
Me.SelectNextControl(Me.radMaskedEditBox1, true, false, false, true)
AddHandler radMaskedEditBox1.TextChanged, AddressOf Me.radMaskedEditBox1_TextChanged
End Sub
Private Sub radMaskedEditBox1_TextChanged(ByVal sender As Object, ByVal e As EventArgs)
If (Me.radMaskedEditBox1.Value.ToString = string.Empty)
Then
Me.radMaskedEditBox1.Text = string.Empty
End If
End Sub
|