2013-12-17 91 views
0

我想獲得一些文字以粗體顯示。德爾福ListView字符串在大膽

下面是代碼:

if (mfDeleted in flags) then 
     begin 
     //Font.Style:=[fsBold]; //This is just changing all to bold not just this row 
     s := s + 'Deleted,'; //I need this Deleted string or whole row to be bold. 
     end; 

我怎樣才能做到這一點?

注:參見注釋代碼

回答

6

您需要處理OnAdvancedCustomDrawItemOnAdvancedCustomDrawSubItem。像這樣:

procedure TMyForm.ListViewAdvancedCustomDrawItem(Sender: TCustomListView; 
    Item: TListItem; State: TCustomDrawState; Stage: TCustomDrawStage; 
    var DefaultDraw: Boolean); 
begin 
    Sender.Canvas.Font.Style := [fsBold]; 
end; 

procedure TMyForm.ListViewAdvancedCustomDrawSubItem(Sender: TCustomListView; 
    Item: TListItem; SubItem: Integer; State: TCustomDrawState; 
    Stage: TCustomDrawStage; var DefaultDraw: Boolean); 
begin 
    Sender.Canvas.Font.Style := [fsBold]; 
end; 

很明顯,您需要將這些事件處理程序掛接到適當的事件。你需要添加一些邏輯來確保你只對你打算突出顯示的行/列做這些事情。