Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. MessageString method is not giving action Width [modified]

MessageString method is not giving action Width [modified]

Scheduled Pinned Locked Moved ASP.NET
graphicshelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kumaran21cen
    wrote on last edited by
    #1

    Hi all, I using MessageString method to calculate the string width. It is not giving the proper String Width. Eg: Font = "Arial 8.25"; Font.Style = Regular; string1 = "1234567890123456789012345678901234567890123456789012345678901" If you place this string to the label/TextBox. The actual width is 368px. But when i use graphics.MeasureString method it gives 387.9978. Is there any other method is available to calculate the string / what's the problem in this method. Some article says, Sometimes MeasureString method will give improper values. Is it true? Please tell me if anybody knows... Thanks.

    Thanks & Regards Kumaran

    modified on Monday, July 20, 2009 11:37 PM

    A 1 Reply Last reply
    0
    • K Kumaran21cen

      Hi all, I using MessageString method to calculate the string width. It is not giving the proper String Width. Eg: Font = "Arial 8.25"; Font.Style = Regular; string1 = "1234567890123456789012345678901234567890123456789012345678901" If you place this string to the label/TextBox. The actual width is 368px. But when i use graphics.MeasureString method it gives 387.9978. Is there any other method is available to calculate the string / what's the problem in this method. Some article says, Sometimes MeasureString method will give improper values. Is it true? Please tell me if anybody knows... Thanks.

      Thanks & Regards Kumaran

      modified on Monday, July 20, 2009 11:37 PM

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      MeasureString actuall gives pixel representation of Actual Graphics Text string. It will be working when you are using a canvas to DrawString. Browser text size is not proper for this. I think the actual pixed depends on each browser. So very little help you have other than trial - error method to determine the size of the textbox. Love to see more replies if there is any alternative. :rose::rose:

      Abhishek Sur My Latest Articles Working with Excel using MDAC
      Basics on LINQ and Lambda Expressions
      Create .NET Templates

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups