CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Getting Text point size.

    In VB6 you could use a label or textbox to find the point size of any text..

    Unfortunately i cant seem to find the same for VB.NET (2008) ..

    Any one got any ideas on where i can find it...

    Thanks

    Gremmy..
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Getting Text point size.

    Hey bud! Long time no see / hear!

    You could use the built in MeasureString method from your Graphics object.
    So, you create a Graphics object, then use MeasureString ( with the appropriate Font Size ). Once that is done, you could make a SizeF object, set it equal to the result of the MeasureString method; then, you could get access to the SizeF object's Height & Width objects.

    Have a look at this :
    http://www.thescarms.com/dotnet/MeasureString.aspx

    http://www.codeproject.com/KB/GDI-pl...reStrings.aspx

    http://www.java2s.com/Tutorial/VB/03...sureString.htm

    Hope that helps!

  3. #3
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Getting Text point size.

    Ahhh .. thanks boet.

    I didn't think of looking in the graphics object ..

    I'm formatting text to print receipts and need to center and right justify the text, and for those calcs you need the text point size.

    Wow .. the receipt looks tons better with the right formatting ...

    Thanks...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  4. #4
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Getting Text point size.

    Glad you came right boet!

    Yeah, I agree about the Graphics object. To me it does make sense having the MeasureString in there, but, on the other hand, it causes more work that what it should have, if there was an equivalent in the String class(es). That would be handy one day LOL!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured