0

All is in the title. How can we also make an officehint customisable for each row. Mean when mousemove on a row, display the information of this record (from a db query).

Thanks

Heinrich Ulbricht
  • 10,064
  • 4
  • 54
  • 85
Gwenael
  • 137
  • 1
  • 2
  • 7

2 Answers2

0

You can color individual cells using the CellProperties property of the grid. You can use this to color an entire row:

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;

To fill your office hint with record data I would suggest updating it when the user moves the mouse. Use the MouseToCell function to get row and column under the mouse, then use MyDBAdvGrid.AllCells[ColIndex, RowIndex] to access the cell content.

Heinrich Ulbricht
  • 10,064
  • 4
  • 54
  • 85
0

An Alternative to Heinrich answer is to use the OnGetCellColor event.

This can be use like so:

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

Similarly for the hint:

procedure TDBAdvGrid.DBGridGridHint(Sender: TObject; ARow, ACol: Integer;
  var hintstr: String);
begin
    hintstr := 'your hint text';
end;
Simon
  • 9,197
  • 13
  • 72
  • 115