I want my textbox to fit with any text that I put into it without having scroll bars. Any idea would be greatly appreciate. Thanks.
How to make an auto sized textbox
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Mike GoldRank #50 · 30.6K reputationPosted Aug 18, 2005, 9:00 PM EDT
the TextChanged event. When you get this event, invalidate the textbox.
measure the string inside the textbox in the paint routine and resize the bounds accordingly.
Here is the code:
private void textBox1_TextChanged(object sender, System.EventArgs e)
{
string text = textBox1.Text;Invalidate(textBox1.Bounds);
}
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e){
SizeF size = e.Graphics.MeasureString(textBox1.Text, textBox1.Font);
if (size.Width < textBox1.Font.SizeInPoints * 2){
size.Width = textBox1.Font.SizeInPoints * 2;
}
textBox1.SetBounds(textBox1.Left, textBox1.Top, (
int)size.Width + 7, textBox1.Height);}