Making Standard ComboBox appear flat
http://www.codeproject.com/cs/combobox/ComboBox_appears_flat.asp

解决方案 »

  1.   

    也可以考虑用自定义控件,重写一个COMBOX组件,现在.NET里自定义控件很方便了!
      

  2.   

    textbox+button+CSS 不知行不行?
    还有就是用listbox+button 为什么没有现成 的呢!
      

  3.   

    public class FlatComboBox : System.Windows.Forms.ComboBox
    {
    private System.Drawing.Color m_BorderColorOut;
    private System.Drawing.Color m_BorderColorIn;
    private System.Windows.Forms.ButtonBorderStyle m_BorderColorStyle;

    public FlatComboBox()
    {
    m_BorderColorOut=System.Drawing.SystemColors.ControlDark;
    m_BorderColorIn=System.Drawing.SystemColors.ControlLight;
    BorderColorStyle=System.Windows.Forms.ButtonBorderStyle.Solid;
    } public System.Drawing.Color BorderColorOut
    {
    get
    {
    return this.m_BorderColorOut;
    }
    set
    {
    this.m_BorderColorOut=value;
    this.DrawBorder();
    }
    }
    public System.Drawing.Color BorderColorIn
    {
    get
    {
    return this.m_BorderColorIn;
    }
    set
    {
    this.m_BorderColorIn=value;
    this.DrawBorder();
    }
    }
    public System.Windows.Forms.ButtonBorderStyle BorderColorStyle
    {
    get
    {
    return this.m_BorderColorStyle;
    }
    set
    {
    this.m_BorderColorStyle=value;
    this.DrawBorder();
    }
    }
    protected override void WndProc(ref System.Windows.Forms.Message m)
    {
    // if (m.Msg ==515)//m.Msg == 675mouseleave;512mousemove;m.Msg==256keydown;m.Msg ==257keyup;m.Msg ==514leftbuttonup;m.Msg ==513leftbuttondown;m.Msg ==515WM_LBUTTONDBLCLK
    // {
    // return;
    // }
    if (m.Msg==0xf || m.Msg==0x133)
    {
    this.DrawBorder();
    }
    base.WndProc (ref m); if (m.Msg==0xf || m.Msg==0x133)
    {
    this.DrawBorder();
    }
    }
    private void DrawBorder()
    {
    System.Windows.Forms.ControlPaint.DrawBorder(this.CreateGraphics(),new System.Drawing.Rectangle(1,1,this.Width-2,this.Height-2),this.m_BorderColorIn,this.m_BorderColorStyle);
    System.Windows.Forms.ControlPaint.DrawBorder(this.CreateGraphics(),new System.Drawing.Rectangle(0,0,this.Width,this.Height),this.m_BorderColorOut,this.m_BorderColorStyle);
    }
    }