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
Hello Stephen,
Thank you for contacting Infragistics.
It's not really possible to display an indicator inside the cell since different characters can be different widths. What I would suggest is using a label or status bar outside of the grid to display the current length of the text in the cell. You would get this length by handling the CellChange event of the grid and accessing e.Cell.Text.Length inside the event handler.
Dave,
Thanks for the fast response.
The forums threw an error when I posted my edit, so I had to try and edit my post a second time and apparently I omitted the fact that I am using a fixed width font that time around.
Anyhow - in that case character width is the same and therefore not really a hurdle. Also this is an "in house" application so I have total control over the font used and size and don't have to worry about someone else changing them.
This could allow for a "low tech" solution like a background image in the cell but it is not ideal and I would not like to go that route if at all possible.
I have used your solution in one of the predecessors to this application and it was not very well received and dropped altogether in the currently active version.
For the small percentage of time they will actually have to edit the data this may just be something they have to live with or maybe I can do something with the text length and selection start properties on edit of the cell. I'll keep digging, just wondered if anyone else had crossed this bridge or had a better solution.
Thanks Again
Steve