How to limit the number of characters in a texbox

Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
Post Reply
kullboys
Posts: 1
Joined: Mon Jun 18, 2018 2:15 am

How to limit the number of characters in a texbox

Post by kullboys »

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.

stasKanRich
Posts: 12
Joined: Tue Jun 05, 2018 12:10 pm

Re: How to limit the number of characters in a texbox

Post by stasKanRich »

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.
Attachments
Untitl2ed.png
Untitl2ed.png (134.51 KiB) Viewed 5273 times

stasKanRich
Posts: 12
Joined: Tue Jun 05, 2018 12:10 pm

Re: How to limit the number of characters in a texbox

Post by stasKanRich »

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#)

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 ;
}
use the corrected in the textbox
and call that from some periodic/timed function from the screen ?

wlederer
Posts: 175
Joined: Fri Jan 27, 2012 4:20 am

Re: How to limit the number of characters in a texbox

Post by wlederer »

Hi, use script.
Globals.Tags.MyTag_rounded.Value =Math.Round((double)Globals.Tags.MyTag.Value,1);//rounds value to 1 decimal

Post Reply