Measure String Size In Pixels (C#) (dev102.com)

submitted by shaharyrshaharyr(4325) 3 years, 4 months ago

Sometimes we need to know the width of a given string in pixels, do you know how to compute it? Before writing some long code, please notice that the .NET framework class library provides such a method...

1 comment |category: |Views: 941

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by TweeZzTweeZz(77) 3 years, 4 months ago 0

What about finding out the amount of pixels a string will take in a browser? You do not necessarily know any font information before hand, because some designer is taking care of the css.
Or let's say you get a request to display '...' at the end of a string when it doesn't fit in the provided space. The string can off course be displayed on only one row.

Reply

information Login or create an account to comment on this story