Click here to Skip to main content
13,259,194 members (53,297 online)
Rate this:
Please Sign up or sign in to vote.
See more:
How to auto resize a textbox in C#?
Posted 15-Oct-10 3:35am
Updated 15-Oct-10 3:44am
Johnny J.170K
Aarti2010 15-Oct-10 8:44am
r u talking about web aur window
if web then sandeep answer is correct.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Your question is too short to get your actual scenario.
Does this help: Resize a TextBox on a Form [^]
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

private void textBox1_TextChanged(object sender, EventArgs e) {
        Size sz = new Size(textBox1.ClientSize.Width, int.MaxValue);
        TextFormatFlags flags = TextFormatFlags.WordBreak;
        int padding = 3;
        int borders = textBox1.Height - textBox1.ClientSize.Height;
        sz = TextRenderer.MeasureText(textBox1.Text, textBox1.Font, sz, flags);
        int h = sz.Height + borders + padding;
        if (textBox1.Top + h > this.ClientSize.Height - 10) {
            h = this.ClientSize.Height - 10 - textBox1.Top;
        textBox1.Height = h;

do vote if answer is helpful

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.171114.1 | Last Updated 15 Oct 2010
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100