我用下代码实现了在ComboBox前加载图标,但有两个地方还没搞懂1, 为什么选择框那里有个矩形框围着,要怎样才能去掉 ?
2,ImageList1里我只放了一个图标,但ComboBox里我Add了很多项,怎样让每项内容前面都显示图标
谢谢procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
ComboBox1.Canvas.FrameRect(Rect);
//在组合框中绘制图标
ImageList1.Draw(ComboBox1.Canvas,Rect.Left,Rect.Top,Index,true);
//在组合框中绘制文本
ComboBox1.Canvas.TextOut(Rect.Left+20,Rect.Top,ComboBox1.Items.Strings[Index]);
end;procedure TForm1.FormCreate(Sender: TObject);
begin
Combobox1.ItemIndex :=0;
end;
2,ImageList1里我只放了一个图标,但ComboBox里我Add了很多项,怎样让每项内容前面都显示图标
谢谢procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
ComboBox1.Canvas.FrameRect(Rect);
//在组合框中绘制图标
ImageList1.Draw(ComboBox1.Canvas,Rect.Left,Rect.Top,Index,true);
//在组合框中绘制文本
ComboBox1.Canvas.TextOut(Rect.Left+20,Rect.Top,ComboBox1.Items.Strings[Index]);
end;procedure TForm1.FormCreate(Sender: TObject);
begin
Combobox1.ItemIndex :=0;
end;
解决方案 »
- 用delphi7加载spcomm.pas时候出现的错误 在线等结果
- 如何操作窗体右上角的 那两个按钮.
- 需要TMS INTRAWEB 9.0.15 for D2007 的源码文件。
- 关于listview的问题
- 推荐一个申请免费域名的网址和方法
- 如何将一个位图对象打印出来?怎么大小不一样?
- 我建了一个access数据库,没有什么密码的,但是用bde来联的时候要输用户名和密码,是什么?
- 看看这里,收获会很大...
- 高分相送!100 请说明update语句的错误原因及解决方法!!!!
- 求援C/S的程序开发
- 如何实现dll中的窗体最小化后显示在任务栏上,而不是显示在MDI窗体内
- 我的数据库恢复之后显示成功,但数据还是原来的数据!请高手指点,在线等
===================================================================================ImageList1.Draw(ComboBox1.Canvas,Rect.Left,Rect.Top,0,true);
begin
if (Selected = true) then//注意这里
begin
Item.Selected := false;//注意这里
Exit;
end;
end;
但是还要加判断,不然你会全部都选不上的