---
title: "Multiline textbox auto height"  
description: "Multiline textbox auto height"  
author: "Manoj Bhatt"  
published: 2013-09-03  
updated: 2013-09-03  
canonical: https://www.mindstick.com/forum/1425/multiline-textbox-auto-height  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# Multiline textbox auto height

I have [multiple](https://www.mindstick.com/blog/12797/iowa-is-expected-to-see-heavy-growth-in-multiple-sectors) multiline textboxes that I fill from a [database table](https://www.mindstick.com/forum/159366/how-to-test-regular-expressions-in-sql-without-using-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](https://www.mindstick.com/forum/12714/dynamic-textbox-in-gridview) data back to the db) the multiline [text boxes](https://www.mindstick.com/forum/34261/how-to-split-data-to-text-boxes-when-read-qr-code-data) do not adjust back to the height they should be, showing all [rows of data](https://www.mindstick.com/forum/157166/what-is-the-best-and-fast-way-to-insert-2-million-rows-of-data-into-sql-server). I figured out a non elegant way to resize the textboxes accordingly. I find the # of [characters](https://answers.mindstick.com/qa/42112/who-is-the-originator-of-avengers-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](https://www.mindstick.com/interview/33859/how-to-create-pixel-counter-in-javascipt) 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](https://www.mindstick.com/articles/23207/how-to-find-the-best-fit-job-for-anyone) have any [ideas](https://www.mindstick.com/articles/43878/making-the-best-use-of-the-options-trade-ideas)?

## Replies

### Reply by Sumit Kesarwani

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.


---

Original Source: https://www.mindstick.com/forum/1425/multiline-textbox-auto-height

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
