我想让ComboBox里面只显示Icon,就是说让客户选择图标的一个ComboBox,而且尽量是大图标(32*32),该怎么做呢?

解决方案 »

  1.   

    我就不灌水啦,
    我在这里有发过一贴类似回复的,应该可以抛砖引玉
    http://expert.csdn.net/Expert/TopicView1.asp?id=1354512
      

  2.   

    除了ComboBox1.Style = csOwnerDrawFixed,还有两个属性如下设置:
    ComboBox1.ItemHeight = 32;
    ComboBox1.DropDownCount = 2;
    再适当调整一下它的宽度。在Form上放一个TImageList,把它的Height属性设为32,然后随便加几个OICQ的bmp文件;
    在ComboBox的OnDrawItem事件里——procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    begin
      ComboBox1.Canvas.Brush.Color := clWindow;
      if odSelected in State then ComboBox1.Canvas.Brush.Color := clHighLight;
      ComboBox1.Canvas.FillRect(Rect);
      ImageList1.Draw(ComboBox1.Canvas, Rect.Left, Rect.Top, Index);
    end;为了初始化ComboBox里Items的个数,可以在它的OnDropDown事件里——procedure TForm1.ComboBox1DropDown(Sender: TObject);
    begin
      if ComboBox1.Items.Count <> ImageList1.Count then
        ComboBox1.Items.Text := StringOfChar(#13, ImageList1.Count);
    end;
      

  3.   

    用delphi7就ok了
    他自带了comboboxEx控件,不用自己操心了