Here, I gave a TextBox resize in C#.net.user can call this function in form load event.
private void txtWidth(TextBox txt)
{
System.Drawing.Graphics g = txt.CreateGraphics();
float maxwidth = 0f;
float w = g.MeasureString(txt.Text, txt.Font).Width;
if (w > maxwidth)
{
maxwidth = w;
g.Dispose();
txt.Width = (int)maxwidth;
}
}
{
System.Drawing.Graphics g = txt.CreateGraphics();
float maxwidth = 0f;
float w = g.MeasureString(txt.Text, txt.Font).Width;
if (w > maxwidth)
{
maxwidth = w;
g.Dispose();
txt.Width = (int)maxwidth;
}
}