这个问出这么高的分, 先占个位.
这年头挣分不容易, 我一点点分析出来.
首先该事件清单如下:
procedure TForm1.ListView1AdvancedCustomDrawSubItem(
Sender: TCustomListView; Item: TListItem; SubItem: Integer;
State: TCustomDrawState; Stage: TCustomDrawStage;
var DefaultDraw: Boolean);
Sender: TCustomListView //即目标视图组件
Item//为所属条目,通谷的说应该就是指当前所会的哪一行.
SubItem//子列,因为ListView支持多个列,所以该数值为列的索引
State//为该行当前所处的状态,看一下就会现他是一个集合结构可以同时包函多种状态
cdsSelected, cdsGrayed, cdsDisabled, cdsChecked,cdsFocused, cdsDefault, cdsHot, cdsMarked, cdsIndeterminate
Stage//这一项作用不明,可以搜索一下这方面的资料
DefaultDraw//表示是否使用该组件默认的绘制方式.
好了, 画星星开始了.
function TForm1.GetSubItemLeft(Index: Integer): Integer;
var
ix: Integer;
begin
result := 0;
for ix:=0 to Index-1 do
result := result +ListView1.Column[ix].Width;
end;
procedure TForm1.ListView1AdvancedCustomDrawSubItem(
Sender: TCustomListView; Item: TListItem; SubItem: Integer;
State: TCustomDrawState; Stage: TCustomDrawStage;
var DefaultDraw: Boolean);
var
Icon: TIcon;
ARect: TRect;
ix: Integer;
sleft: integer;
const
scount = 5;
begin
with Sender do begin
if (SubItem = 2) then begin //注:2表示,要在第2列画星星. 可以改成其它的
Icon := TIcon.Create;
ImageList1.GetIcon(0, Icon);
ARect := Item.DisplayRect(drBounds);
sleft := GetSubItemLeft(SubItem);
for ix := 1 to scount do begin
Sender.Canvas.Draw(sleft, ARect.Top, Icon);
sleft := sleft +Icon.Width +1;
end;
DefaultDraw := false;
end;
end;
end;