2011-08-18 21 views

回答

0

您可以使用網格的CellProperties屬性color單個細胞。您可以使用此上色整行:

var 
    RowIndex: Integer; 
    ColIndex: Integer; 

with MyDBAdvGrid do 
begin 
    // you choose the row index; you may want to iterate all rows to 
    // color each of them 
    RowIndex := 2; 
    // now iterate all (non-fixed, visible) cells in the row and color each cell 
    for ColIndex := FixedCols to ColCount - 1 do 
    begin 
    CellProperties[ColIndex, RowIndex].BrushColor := clYellow; 
    CellProperties[ColIndex, RowIndex].FontColor := clGreen; 
    end; 
end; 

要使用記錄數據,我建議當用戶移動鼠標更新它填補你的辦公室提示。使用MouseToCell函數獲取鼠標下的行和列,然後使用MyDBAdvGrid.AllCells[ColIndex, RowIndex]來訪問單元格內容。

+0

感謝它,但是當u告訴CellPropierties,意味着對哪些事件? – Gwenael

+0

某些事件指示數據更改。這取決於你如何使用你的網格。有這麼多的事件在這件事上... –

0

Heinrich答案的替代方法是使用OnGetCellColor事件。同樣

procedure TDBAdvGrid.DBGridGetCellColor(Sender: TObject; ARow, 
    ACol: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont); 
begin 
    if (your condition) then ABrush.Color := clRed; 
end; 

的提示:

這可以使用像這樣

procedure TDBAdvGrid.DBGridGridHint(Sender: TObject; ARow, ACol: Integer; 
    var hintstr: String); 
begin 
    hintstr := 'your hint text'; 
end; 
+0

謝謝,但以這種方式,它只顯示顏色,當我點擊行。 – Gwenael

+0

是否可以在不移動光標的情況下做同樣的事情? Thakns – Gwenael

+0

您可能需要考慮AState屬性。 – Simon

相關問題