Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • 4 weeks later...
  • *Experts*
Posted

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:

Dim gr As Graphics = Me.CreateGraphics()
Dim wth As Single = gr.MeasureString("Some text is there", Me.Font).Width

Posted

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 it's 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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...