.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Melody Anderson

Home >> Code Snippets >> Windows Form Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Resize TextBox in C#.net

Posted By:Narayanan       Posted Date: March 11, 2012    Points: 40    Category: Windows Form Controls    URL: http://www.dotnetspark.com  

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;

txt.Width = (int)maxwidth;


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend