Q
QSmile
Unregistered / Unconfirmed
GUEST, unregistred user!
我把 TListView 的 设为自画.
再在 OnDrawItem 中写入
var
bkcolor,ftcolor:TColor;
i:Integer;
x:integer;
begin
if odSelected in state then
begin
bkcolor:=$00C56549;
ftcolor:=clWhite;
end
else begin
ftcolor:=clBlack;
if Item.Index mod 2 = 0 then
bkcolor:=$00F2FAFD
else
bkcolor := clWhite;
end;
with TListView(Sender) do
begin
Canvas.Brush.Color:=bkColor;
Canvas.Font.Color:=ftcolor;
Canvas.FillRect(Rect);
if SmallImages<>nil then
begin
SmallImages.Draw(Canvas,Rect.Left+1,Rect.Top+1,Item.ImageIndex);
Canvas.TextOut(Rect.left+1+SmallImages.width,Rect.Top+1,Item.caption);
end
else
Canvas.TextOut(Rect.left+1,Rect.Top+1,Item.caption);
x := 1;
for i:= 0 to Item.SubItems.Count -1 do
begin
x:= x + TListView(Sender).Columns.Width ;
Canvas.TextOut(x+2,Rect.Top +1, Item.SubItems);
end;
end;
这样显示都正常,但如果拉动了上面的 Column 后,下面上一次自画的内容不会消失呢?
如何处理?
比如我拉第三列,向后拉.这时以前第三列显示的内容还在那里.要如何修?.
再在 OnDrawItem 中写入
var
bkcolor,ftcolor:TColor;
i:Integer;
x:integer;
begin
if odSelected in state then
begin
bkcolor:=$00C56549;
ftcolor:=clWhite;
end
else begin
ftcolor:=clBlack;
if Item.Index mod 2 = 0 then
bkcolor:=$00F2FAFD
else
bkcolor := clWhite;
end;
with TListView(Sender) do
begin
Canvas.Brush.Color:=bkColor;
Canvas.Font.Color:=ftcolor;
Canvas.FillRect(Rect);
if SmallImages<>nil then
begin
SmallImages.Draw(Canvas,Rect.Left+1,Rect.Top+1,Item.ImageIndex);
Canvas.TextOut(Rect.left+1+SmallImages.width,Rect.Top+1,Item.caption);
end
else
Canvas.TextOut(Rect.left+1,Rect.Top+1,Item.caption);
x := 1;
for i:= 0 to Item.SubItems.Count -1 do
begin
x:= x + TListView(Sender).Columns.Width ;
Canvas.TextOut(x+2,Rect.Top +1, Item.SubItems);
end;
end;
这样显示都正常,但如果拉动了上面的 Column 后,下面上一次自画的内容不会消失呢?
如何处理?
比如我拉第三列,向后拉.这时以前第三列显示的内容还在那里.要如何修?.