h1.post-title { color:orange; font-family:verdana,Arial; font-weight:bold; padding-bottom:5px; text-shadow:#64665b 0px 1px 1px; font-size:32px; } -->

Pages

Resize 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;
            }
            g.Dispose();
            cmb.Width = (int)maxwidth + 20;
        }