Hello everyone
Trying to limit the number of characters a textbox can accept. There is no MaxLength property available. I have tried using the TextBox that comes through "Add Control" but it has no option to attach a tag. To summarize I am looking for a textbox control that can be attached to a tag and that has a MaxLength kind of property.
Thanks.
How to limit the number of characters in a texbox
-
- Posts: 12
- Joined: Tue Jun 05, 2018 12:10 pm
Re: How to limit the number of characters in a texbox
hi,
not sure if this fixes your problem but you can do this by the validation section in the Analog numeric. it has lower limit and upper limit.
not sure if this fixes your problem but you can do this by the validation section in the Analog numeric. it has lower limit and upper limit.
- Attachments
-
- Untitl2ed.png (134.51 KiB) Viewed 7366 times
-
- Posts: 12
- Joined: Tue Jun 05, 2018 12:10 pm
Re: How to limit the number of characters in a texbox
another idea.
create a new tag to have the "corected version"
so you will have two tags in your tags view:
yourOriginalTag ( data from where ever)
yourOriginalTag_corrected ( HMI tag will be changed by c#)
use the corrected in the textbox
and call that from some periodic/timed function from the screen ?
create a new tag to have the "corected version"
so you will have two tags in your tags view:
yourOriginalTag ( data from where ever)
yourOriginalTag_corrected ( HMI tag will be changed by c#)
Code: Select all
int minNum = 12 ;
int maxNum = 123 ;
var origTag = Globals.Tags.yourOriginalTag ;
var cappedTag = Globals.Tags.yourOriginalTag_corrected;
if (Globals.Tags.yourOriginalTag.Value < minNum )
{
Globals.Tags.yourOriginalTag.Value = minNum ;
}
if (Globals.Tags.yourOriginalTag.Value > maxNum )
{
Globals.Tags.yourOriginalTag.Value = maxNum ;
}
and call that from some periodic/timed function from the screen ?
Re: How to limit the number of characters in a texbox
Hi, use script.
Globals.Tags.MyTag_rounded.Value =Math.Round((double)Globals.Tags.MyTag.Value,1);//rounds value to 1 decimal
Globals.Tags.MyTag_rounded.Value =Math.Round((double)Globals.Tags.MyTag.Value,1);//rounds value to 1 decimal