I’m trying to simulate the MaxLength property (which is no longer available) on a RadMaskEditBox and I use:
radMaskedEditBox1.MaskType = MaskType.Standard;
radMaskedEditBox1.Mask = “aaaaa”;
I set programmatically a first value in my RadMaskedEditBox1, “ABCDE”. The displayed value on my control is, as expected, “ABCDE”.
Then I try to set another value, "XX”, and I notice that de displayed value of the control is “XXCDE”.
Any idea? How can I use masks to limit the chars n° in the RadMaskEditBox?
Thank you
L.E.: RadControls version 2013.3.1127.40
10 Answers, 1 is accepted
Thank you for writing.
When you have initialized the mask like this you cannot enter more than five letters (your length is limited to 5 letters). Then also when you are setting the text like this it will only change the first two letters. To clear the remaining letters you can either clear the entire box or to set some spaces after the desired text:
radMaskedEditBox1.Text =
new
string
(
' '
, radMaskedEditBox1.Text.Length);
radMaskedEditBox1.Text =
"XX "
;
I hope this will be useful. Should you have further questions, I would be glad to help.
Dimitar
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
This might be a solution, but I think the mask "aaaaa" means "5 alphanumeric optional char".
Adding some trailing characters just to erase the MaskedEditBox's content it's not coherent...
Thanks again, I'll try to use your solution.
Best regards,
Catalin
Thank you for writing back.
This is how RadMaskedEditBox is working (every character is validated or changed separately) and this is the default behavior by design.
Do not hesitate to contact us if you have other questions.
Dimitar
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Hi,
I want to Implement the validation provider for a required field.
I think we need the RadMaskedEditBox ?
How can I set the RadMaskedEditBox to allow any alpha numeric data ( at least one caracter : so as a required field) ,in order to integrate this with the validation Provider ?
( For Telerik Winfoms 2020 C# )
Thanks,
Fahmi
RadMaskedEditBox is a suitable control if you want to restrict the users' input. You can find listed all mask types in the following help article: https://docs.telerik.com/devtools/winforms/controls/editors/maskededitbox/mask-types-and-providers
For the Standard mask type you can specify very precisely what characters are allowed: https://docs.telerik.com/devtools/winforms/controls/editors/maskededitbox/standard-masks
If none of the built-in mask types are suitable for your case, RadValidationProvider offers an alternative approach for validating users' data of any control that you have on the form: RadTextBox, RadSpinEditor, etc.
The following resources are quite useful about getting started experience with the component:
https://docs.telerik.com/devtools/winforms/controls/validation-provider/overview
https://docs.telerik.com/devtools/winforms/controls/validation-provider/getting-started
https://www.telerik.com/blogs/ensuring-data-validity-winforms-applications-without-writing-code
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).
Thanks Dess, this should cover all my requests/needs for now.
Have a nice weekend.
Hi Dess,
I've implemented this, but it's generating an error on validation ( Object reference not set to an instance of an object )
The first validation rules works perfectly, but the rule for : Integer grater then 0 is apparently causing an issue.
Also, I've a validation for a picture to be selected ( picture box ) : I make a test on the generated Path: can this be integrated in the validation Provider in order to display the Icon "Image required" if the path is empty.
Please note that Path is a variable in code behind and not a RadTextBox.
Thanks,
Fahmi
Also the RadSpinEditor behaves abnormally when a validation rule is attached: you can't delete easily the input and typing is right to left also last number can be deleted. In addition, you can deleted only with the "delete" keyboard key and not using the "back" keyboard key.
I hope this is a configuration issue and I don't have to wait until next release to be fixed.
Hello, Fahmi,
It seems that you want to validate a RadTextBox with RadValidationProvider. Please have in mind that RadTextBox offers Text property that stores the text. RadTextBox doesn't provide Value property. Hence, the validation rule doesn't seem to be correctly defined. You should be careful about what properties a certain control has and what is the data type of the respective property. This way the validation rule will be properly defined.
More information about the different validation rules is available here: https://docs.telerik.com/devtools/winforms/controls/validation-provider/validation-rules
According to the provided information, it wouldn't be easy to understand the complete scenario and the exact setup that you have on your end. That is why I would kindly ask you to submit a support ticket from your Telerik account if you have any technical inquiries about the controls in the Telerik UI for WinForms suite. Thus, you can provide a sample project demonstrating the undesired behavior that you are facing. In addition, your ticket will be entitled to response time according to the license support plan and Telerik support engineers would gladly assist you.
Thank you for your understanding.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).