Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
725
MaskInput for text length indicator
posted

In my project I have a grid cell bound to a data point that has a fixed allowable length (36 chars)

There is a routine in the program that attempts to "Auto Build" this data however sometimes due to the other inputs the results is greater than 36 chars.

The user can then make manual corrections to the point to shorten it

What I wanted to be able to do was provide a quick reference point to show when the string was with-in the accepted length.

My first attempt was using a .MaskInput = ">&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&|" but I forgot that this would still truncate the excess string (Duh!)

I was unable to find anything that would just allow "anything" after the pipe regardless of length so I just added 25 more '&' after the pipe character to allow for some excess data - this is 'OK' and will likely be enough space but it causes Column width issues (grid thinks the column should be wide enough to accommodate the full mask even when there's no data) and when the cell enters edit mode for the user to make corrections the MaskInput makes the cell / string act like there are padded white spaces on the end instead of going to the last visible character as one would expect.

Is there some format string character or MaskInput option that I'm missing that will allow for a non-fixed length of trailing characters after the pipe or is there a different / better way to tackle this problem than using an Input Mask?

Thanks in advance for your help.

Stephen

Edit - the allowable length is constrained in the database on the back end and I handle trimming the data prior to save. I have not constrained the column in any way (i.e. maxlength) so as to allow the display of the auto generated data