Textbox minimum height and width

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chuck Bowling

    Textbox minimum height and width

    I'm trying to figure out how I can get the minumum height required for a
    textbox containing a string in a given font with a set width and also the
    converse, the minimum required width of a textbox with a set height.

    I want a textbox that is resized to fit the text inside with either the
    height or width locked. Anybody have a suggestion on how I might go about
    doing that?


  • Maqsood Ahmed

    #2
    Re: Textbox minimum height and width

    Hello,
    Well, I know that how to find string width/height when width is
    locked. You can use Graphics.Measur eString(string, Font,int) method. It
    takes the string, Font and Maximum width of the string. It returns SizeF
    structure. You can convert it to Size structure using it's .ToSize()
    method.

    HTH. Cheers
    Maqsood Ahmed [MCP,C#]
    Kolachi Advanced Technologies


    *** Sent via Developersdex http://www.developersdex.com ***

    Comment

    • Chuck Bowling

      #3
      Re: Textbox minimum height and width

      Thank you for the reply. Unfortunately, this doesn't take into account the
      word wrap feature of the TextBox control. It would be relatively easy to
      find text height if I knew how many lines are wrapped in the control.

      "Maqsood Ahmed" <maqsood_ahmed@ gawab.com> wrote in message
      news:eL4pyyzYFH A.2768@tk2msftn gp13.phx.gbl...[color=blue]
      > Hello,
      > Well, I know that how to find string width/height when width is
      > locked. You can use Graphics.Measur eString(string, Font,int) method. It
      > takes the string, Font and Maximum width of the string. It returns SizeF
      > structure. You can convert it to Size structure using it's .ToSize()
      > method.
      >
      > HTH. Cheers
      > Maqsood Ahmed [MCP,C#]
      > Kolachi Advanced Technologies
      > http://www.kolachi.net
      >
      > *** Sent via Developersdex http://www.developersdex.com ***[/color]


      Comment

      Working...