Question

I'm using a TextBox to create an editable title on something that looks like a post-it note. I changed to a TextBox from a RichEditBox to see if that could solve my problem, which it didn't, so I'm willing to change back if that helps.

My problem is that I don't want the user to be able to enter more characters than fit in the set width of the TextBox, because I want the whole title to be visible. Setting a fixed limit to the amount of characters that can be entered doesn't really work since for example 10 large M's would fill the width of my TextBox, but other characters will only fill half of it. So I would like to compare the width of the text to the width of the TextBox, so I can restrict input beyond that point.

Edit: I'm using the Segoe UI font, and I don't really consider changing the font to one with characters of equal width as a solution.

No correct solution

OTHER TIPS

Set the TextBox Font to a Courier Font, then all characters are equal width and calculating max becomes trivial.

Max value telling by hard coding .

I am suck in programming world. i m try help you..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top