2011-07-04 54 views
0

我有一個ListView(vsReport):最後一個SubItem有一個文本「等待」。然後我會將其更改爲「ok」或「error」。如何在綠色(ok)和紅色(錯誤)中繪製整行(如果在CustomDrawItem中使用Sender.Canvas.Brush.Color,它將成爲Windows 7中列之間的間隙)?德爾福:繪製行ListView

謝謝!

回答

1

你可以針對它做

procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView; 
    Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean); 
begin 
    if Item.Index = Sender.Items.Count - 1 then 
    begin 
    Sender.Canvas.Brush.Color := clSkyBlue; 
    Sender.Canvas.FillRect(Item.DisplayRect(drBounds)); 
    end; 
end; 

,但我的意見,因爲它是越野車(我不知道如何解決它)。

Screenshot http://privat.rejbrand.se/listviewentirerowfill.png

+0

到底是什麼這個方法越野車,好嗎? –

+0

嘗試移動鼠標,你會看到:) – maxfax

+0

我有很多應用程序,他們都通常沒有空白的油漆。我從來沒有一個程序在ListView中有空白。 – maxfax