0

一切尽在标题中。我们如何也可以为每一行定制一个 officehint。意味着当鼠标移动一行时,显示该记录的信息(来自数据库查询)。

谢谢

4

2 回答 2

0

CellProperties您可以使用网格的属性为单个单元格着色。您可以使用它为整行着色:

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]获取单元格内容。

于 2011-08-18T11:19:27.000 回答
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;
于 2011-08-19T02:38:03.640 回答