Determine Label Size based upon amount of text and font size in Winforms/C#

前端 未结 11 1761
半阙折子戏
半阙折子戏 2020-11-30 01:27

I\'d like to know if there\'s a better approach to this problem. I want to resize a label (vertically) to accomodate certain amount of text. My label has a fixed width (abou

11条回答
  •  长情又很酷
    2020-11-30 02:17

    Well the 60 chars might be valid for your test text, but not all characters have the same width. For instance, compare
    llllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
    and
    wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww

    They both have 60 characters, and yet have vastly differing widths.

提交回复
热议问题