在combobox中画出图片了,但显示图片的大小怎么就是无法改变,改combobox的大小也没用,只不是只有改e.Graphic啊,要如何改啊
private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index != -1)
            {
                Graphics g = e.Graphics;
                Rectangle r = e.Bounds;
                Size imageSize = imglist.ImageSize;
                Font fn = null;
                if (e.Index >= 0)
                {
                    fn = new Font("Ariel ", 12, FontStyle.Bold);
                    string s = (string)cmbbox.Items[e.Index];
                    StringFormat sf = new StringFormat();
                    sf.Alignment = StringAlignment.Near;
                    if (e.State == (DrawItemState.NoAccelerator | DrawItemState.NoFocusRect))
                    {
                        //画条目背景 
                        e.Graphics.FillRectangle(new SolidBrush(Color.Red), r);
                        //绘制图像 
                        imglist.Draw(g, r.Left, r.Top, e.Index);
                        //显示字符串                      
                        e.Graphics.DrawString(s, fn, new SolidBrush(Color.Black), r.Left + imageSize.Width, r.Top);
                        //显示取得焦点时的虚线框 //
                        e.DrawFocusRectangle();
                    }
                    else
                    {
                        e.Graphics.FillRectangle(new SolidBrush(Color.White), r);
                        imglist.Draw(e.Graphics, r.Left, r.Top, e.Index);
                        e.Graphics.DrawString(s, fn, new SolidBrush(Color.Black), r.Left + imageSize.Width, r.Top);
                        e.DrawFocusRectangle();
                    }
                }
            }
        }

解决方案 »

  1.   

    把imglist中图标尺寸(ImageSize)加大
      

  2.   

    我试过了,没用啊,在开始加了一句imglist.ImageSize = new Size(30, 30);一运行到else里的imglist.Draw()就报错,An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in System.Windows.Forms.dllAdditional information: InvalidArgument=Value of '0' is not valid for 'index'
      

  3.   

    在属性列表里改imageSize就可以了,但为什么不能动态的改啊