[VB.NET]Text height

stordaz

Member
Joined
Apr 15, 2003
Messages
16
Location
Italy
Hi

How can I know the height of a text in a textbox;
I mean the job of the old Textheight property.

Thanks
 
i dont know much about vb.net but in c# it would be

int height = myTextBox.Font.Height;

myTextBox is the name of the object which is a TextBox


should be quite similar to vb.net i think
 
You can get the width of text using the MeasureString method of a graphics object which will then return the size based on the string and the font you used:
Code:
Dim gr As Graphics = Me.CreateGraphics()
Dim wth As Single = gr.MeasureString("Some text is there", Me.Font).Width
 
This is a little different, but wondering if MeasureString could be used in the following.

I am making reports and need to show data in columns. Problem is with TT Fonts, the letter widths all vary, so its hard to align them to so they look right justified.

Is the MeasureString accurate enough to be able to work out the start position and end up having them aligned correctly.
 
Back
Top