Adding Images to Menu
http://www.codeproject.com/cs/menu/menucontrolimage.asp
http://www.codeproject.com/cs/menu/MenuControlImage/MenuControlImage_src.zip

解决方案 »

  1.   

    protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
    {
    e.DrawBackground();
    e.Graphics.FillRectangle(new System.Drawing.SolidBrush(e.BackColor),e.Bounds.Left,e.Bounds.Top,e.Bounds.Width-1,e.Bounds.Height-1);
    if (this.m_Icon!=null)
    {
    e.Graphics.DrawIcon(this.m_Icon,new System.Drawing.Rectangle(e.Bounds.Left+2,e.Bounds.Top+(e.Bounds.Height-this.m_Font.Height)/2,16,16));
    }
    e.Graphics.DrawString(this.Text,this.m_Font,new System.Drawing.SolidBrush(e.ForeColor),e.Bounds.Left+20,e.Bounds.Top+(e.Bounds.Height-this.m_Font.Height)/2);
    base.OnDrawItem (e);
    }

    protected override void OnMeasureItem(System.Windows.Forms.MeasureItemEventArgs e)
    {
    e.ItemHeight=this.m_ReferrenceHeight;
    e.ItemWidth=this.m_ReferrenceWidth;
    base.OnMeasureItem (e);
    }
    一个小小的参考:)