现在c# winform中的combobox控件里的字体太小了,虽然可以修改里的字体大小,但是combobox控件本身也就跟着变大了,界面上显示不整齐,能不能实现只是下拉菜单里的字体变大,比方说点击下来菜单的时候,而combobox控件本身不会变大?谢谢哦~~~~~~~~~~~~~~~~~

解决方案 »

  1.   

    需要重绘类似
    http://stackoverflow.com/questions/3789596/combobox-appearance
      

  2.   


    protected override void OnDrawItem(DrawItemEventArgs e)
            {
                e.DrawBackground();
                if (e.State == DrawItemState.Focus)
                    e.DrawFocusRectangle();
                var index = e.Index;
                if (index < 0 || index >= Items.Count) return;
                var item = Items[index];
                string text = (item == null) ? "(null)" : item.ToString();
                using (var brush = new SolidBrush(e.ForeColor))
                {
                    Font f = new Font(e.Font.Name,e.Font.Size+10);//改变font字体
                    e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
                    e.Graphics.DrawString(text, f, brush, e.Bounds);
                }
            }
    楼主,不好意思,曹版的地址里的代码,我简单的读了读,目前这个只能改变字体大小,那个显示的区域没有跟着改变,给你参考下(我加了注释的语句),你拿去举一反三的把那个显示区域大小也改了就好了