I have a report that I need to increase the size of the textbox base on the length of the text. There some formula to calculate the resulting lenght size?
+1
A:
You can either go for a Label with the AutoSize property set to True. Or if you want to stick to TextBox, you can make use of MeasureString method and get the width of the text from there. Use that width to set the width of TextBox.
danish
2010-05-06 16:41:23
That help but still did not get the desire width. Is giving me like 80 character width. this is my code Dim objBitmap As Bitmap = New Bitmap(1000, 1000) Dim g As Graphics = Graphics.FromImage(objBitmap) Me.fldDescription.Width = g.MeasureString(Trim(Me.fldDescription.Text), Me.fldDescription.Font).Width g.Dispose() objBitmap.Dispose()
Gregorio J. Placeres
2010-05-06 17:25:21
Get the result after several trial dividing the width/99
Gregorio J. Placeres
2010-05-06 17:48:00