Since there isn't a built-in context menu for a MaskedEdit, I tried to add one. However, I can't get it to display.
I added a contextMenuStrip and then added a menuItem.
I added the menuItem click event
I added the contextMenuStrip to the MaskedEdit field
When I test it (right-click on the field), nothing happens.
I also tried other events on the MaskedEdit field like the mouse click event and it never calls it when I click on the field.
What am I missing? (screenshot attached)
private void miCopy_Click(object sender, EventArgs e)
{
try
{
TextBoxBase thiscontrol;
thiscontrol = (TextBoxBase)ActiveControl;
if (thiscontrol.SelectionLength > 0)
{
thiscontrol.Copy();
}
}
catch (Exception)
{
}
}
Regarding the RadMaskedEditBox using the provided Email MaskType:
The error validation icon displays when there is an error, but it doesn't prevent the user from leaving the field.
How can I prevent the user from leaving the field with this MaskType?
I have a MaskedEditBox called mtbText bound to a string property like this:
mtbText.DataBindings.Add(nameof(mtbText.Value), customerSearch, nameof(customerSearch.Text), false, DataSourceUpdateMode.OnPropertyChanged);
public string? Text
{
get => _text;
set
{
if (_text != value)
{
_text = value;
OnPropertyChanged(nameof(Text));
}
}
}
Sometimes I need a specific mask like SSN or phone # and sometimes I don't. The UI resets the properties on the single mask control depending on need. If I bind to a specific mask like this (say a SSN or phone #) it works fine. However sometimes I need a mask that will allow anything. I tried aaaaaaaaaa and a few other combination but these won't let me enter blank spaces. If I set the MaskType to None it allow the spaces but doesn't bind to the property.
mtbText.Mask = string.IsNullOrEmpty(item.Mask) ? "aaaaaaaaaa" : item.Mask;
mtbText.MaskType = MaskType.Standard;
mtbText.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
What mask can I use that would allow me to enter something like 123 Main Street and still bind to the object property.
Thanks
Carl
I am using the RadMaskedEditBox to limit the user input. I need to allow the user to enter values from 0.0 to 999.9. I was using a MaskType of Standard with a Mask of 999.9 or ###.#...however, this is forcing the user to enter numbers that are < 100 as 099.0. The users down't want to enter 0 for any value below 100, this is a real pain for them. so, I switched it to using a MaskType of Numeric and setting the Mask to N1, but this has its own problem of allowing the user to enter 9999999.9, which when saved, thows an error (the underline field is only 5 characters). Since there is no MaxLenth field on this control, I need a better method. I looked at using REGEX as the masktype, but, to this date, I still struggle with REGEX EXPRESSIONS and how to create an REGEX Expression to make this work. Anyone help me out here.
Thanks.
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
Hi,
I'm getting weird / unexpected behaviour when using the masked edit box configured to handle IP Addresses.
So using the latest Demo Application, I open up the Masked Edit Box, and in the IP edit box I type in 11.22.33.44
I then double click and highlight the 44 part, and type 6 to replace the 44 with a single 6, however the following is displayed
After clicking on OK this then changes to show the ip address as 11.22.33.255 It seems that clicking on 6 does not replace the 44 but gets inserted at the start of the element. Is there a workaround for this behaviour ?
In our application, we are using RadMaskedEditbox for the Phone and Fax values.
We are using the property for MaskType is Standard & Mask is (###) ###-#### & & & & & & & &
Here we need to allow only the numeric value, not special characters. (Do not allow them to enter the hyphen.)
The problem is: https://prnt.sc/xsW5oONnZLN4
Hi. I want to bring a custom control that inherits from RasMaskedEditBox. But onKeyDown and OnKeyPress events do not fired.
public class myMask: Radmaskededitbox
{
protected override void OnKeyDown(KeyEventArgs e)
{
//My codes
}
}
Hi Team,
When click or double click in the field and the full number doesn't get highlighted on the RadMaskedEditbox.
Video Link : https://ttprivatenew.s3.amazonaws.com/pulse/suganya-gmail/attachments/16655538/TinyTake24-04-2021-01-52-14.mp4
We need to load the Phone number Textbox value as 713-000-0000 ("(###) ###-####") while loading but when i try to enter the value the RadMaskedEditbox value it should allow to type 18 characters ((###) ###-############)