MULTILINE TEXTBOX AUTO HEIGHT

Manoj Bhatt

Total Post:154

Points:1086
Posted by  Manoj Bhatt
C# 
C#
 1920  View(s)
Ratings:
Rate this:

I have multiple multiline textboxes that I fill from a database table. When typing in them the height auto-expands and adjusts in height to the # of rows of text being entered so all rows of text can be seen without scrolling. This is perfect, but when I re-load the page (after I save the textbox data back to the db) the multiline text boxes do not adjust back to the height they should be, showing all rows of data. I figured out a non elegant way to resize the textboxes accordingly. I find the # of characters in the entire multiline textbox, divide that # by the # of characters that can fit in the row based upon the width I've chosen to get the how many rows there should be, multiply that # by the pixel height of a row, and set the textbox height to this # in pixels. There has to be a more elegant way to do this but I can't find it. Anyone have any ideas?

  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: Multiline textbox auto height

    Hi Manoj,


    You could try disabling the multiline property while focus is away from that control, and when you click the textbox to type, you re-enable multiline.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!