I've a field in a database, this field has a maximum length, and I want to set a textbox to the appropriate width. I'm creating the textboxes in runtime. How can I calculate the value of width property?
For example, if I have a field nvarchar(5) named IDClient, and the font-Size is 13, I want to create a texbox with a width enough to write 5 chars.
Best Solution
Maybe should use TextRenderer.MeasureText(string, font).
Here a little sample which should might help you