Textbox auto-grow in height - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Textbox auto-grow in height

VCGVCG Posts: 51Member
How can I change the height of the textbox programmatically so that it dynamically changes it's own height as I enter more texts in it.

TIA

Comments

  • RelmanRelman Posts: 104Member
    : How can I change the height of the textbox programmatically so that it dynamically changes it's own height as I enter more texts in it.
    :
    : TIA
    :
    Check the text_changed method. Check when e.key = a certain key (Eg. Enter) and then increase the hieght.
    If you are still stuck, I (might) stick some code up for you.
    I am guessing that it is a multi-line textbox, because you can only change the hieght of a normal one by changing the font size.

    Akiva
  • VCGVCG Posts: 51Member
    Thanks

    but I'm still stuck a little bit. I was able to change the height programmatically by doing this:

    textbox1.height = (textbox1.lines.length) * (textbox1.Font.Height)

    however, the formula seems ok if i only have 4 lines of texts in a multi-line textbox. But if I have more (for example 20 rows), the textbox starts to hide some info or texts. This works fine if the fontsize is 8pt. but if I make the fonts a little bigger, then the bigger the problem is.

    I also wanted the formula to adopt to fontsize changes that's why either I need the correct formula, or if there is a way to make the textbox behave as i wanted it by tweaking some properties. thanks.

    Bdway, I have disabled the AutoScroll and Wordwrap property since I don't want them.





    : : How can I change the height of the textbox programmatically so that it dynamically changes it's own height as I enter more texts in it.
    : :
    : : TIA
    : :
    : Check the text_changed method. Check when e.key = a certain key (Eg. Enter) and then increase the hieght.
    : If you are still stuck, I (might) stick some code up for you.
    : I am guessing that it is a multi-line textbox, because you can only change the hieght of a normal one by changing the font size.
    :
    : Akiva
    :

    [blue][size=4][b][italic]VCG[/italic][/b] :-D[/blue][/size]

Sign In or Register to comment.