https://www.packtpub.com/en-us/product/delphi-cookbook-second-edition-9781785287428/chapter/delphi-basics-1/section/using-owner-draw-combos-and-listboxes-ch01lvl1sec12 VCL下ListBox自画,Lazarus也一样 通过百度网盘分享的文件:listBoxOwnerDrawdd.rar链接: https://pan.baidu.com/s/1mwesuIyLHsb6j9PFZNLiTQ 提取码:u181 登录后复制 procedure TForm7.ListBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); var LBox: TListBox; R: TRect; S: string; TextTopPos, TextLeftPos, TextHeight: Integer; const IMAGE_TEXT_SPACE = 4; // 图标 与 文本 之间 的 间隔 begin LBox := Control as TListBox; R := Rect; LBox.Canvas.FillRect(R); ImageList1.Draw(LBox.Canvas, R.Left, R.Top, Index); //画 图标 S := LBox.Items[Index]; TextHeight := LBox.Canvas.TextHeight(S); TextLeftPos := R.Left + ImageList1.Width + IMAGE_TEXT_SPACE; TextTopPos := R.Top + R.Height div 2 - TextHeight div 2 ; LBox.Canvas.TextOut(TextLeftPos, TextTopPos, S); //画 文本 end; 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21. 原创作者: u_15216366 转载于: https://blog.51cto.com/u_15216366/11783708