如何在列表框里显示图标

daiguan 2002-03-06 01:03:49
就像是选桌面背景的那个列表框
...全文
36 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
manboo 2002-03-08
  • 打赏
  • 举报
回复
在把style选成自画后你喜欢怎么画就怎么画啊,先看看帮助先
王集鹄 2002-03-08
  • 打赏
  • 举报
回复
to childbaby(小孩宝贝):
ImageList1必须有图片
ListBox1.Style := lbOwnerDrawFixed; //不可少
王集鹄 2002-03-08
  • 打赏
  • 举报
回复
to childbaby(小孩宝贝):
ImageList1必须有图片
ListBox1.Style := lbOwnerDrawFixed; //不可少
childbaby 2002-03-08
  • 打赏
  • 举报
回复
好象行不通!
daiguan 2002-03-07
  • 打赏
  • 举报
回复
能不能给点代码?谢谢
王集鹄 2002-03-07
  • 打赏
  • 举报
回复
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
Bitmap: TBitmap;
Offset: Integer;
begin
if Index < 0 then Exit;
Bitmap := TBitmap.Create;
with TListBox(Control).Canvas do try
FillRect(Rect);
Offset := 2;
ImageList1.GetBitmap(Index, Bitmap);
if Bitmap <> nil then begin
Draw(Rect.Left + Offset, Rect.Top, Bitmap);
Offset := Bitmap.Width + 6;
end;
TextOut(Rect.Left + Offset, Rect.Top, TListBox(Control).Items[Index]);
finally
Bitmap.Free;
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
ListBox1.Style := lbOwnerDrawFixed;
end;
daiguan 2002-03-07
  • 打赏
  • 举报
回复
帮帮忙
cobi 2002-03-06
  • 打赏
  • 举报
回复
在listbox的ondrawitem事件中处理
数字蛋糕 2002-03-06
  • 打赏
  • 举报
回复
Use OwnerDraw Events:
OnMesureItem & OnDrawItem.

5,391

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧