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

Top 5 Contributors of the Month
Imran Ghani
Sohaib Khalid

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

 Subscribe to Code Snippets

Resize ComboBox 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 Re size of the ComboBox in C#.net

private void cmbwidth(ComboBox cmb)

System.Drawing.Graphics g = cmb.CreateGraphics();
float maxwidth = 0f;
foreach (object o in cmb.Items)
float w = g.MeasureString(o.ToString(), cmb.Font).Width;
if (w > maxwidth)
maxwidth = w;
cmb.Width = (int)maxwidth + 20;



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