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