Can't seem to find an easy way to do this. I've had a look at combining OnMouseMove with repainting the cell, but then OnGetCellColor doesn't provide an easy way of determining if the mouse is over the cell.
Is there a built-in function that I've missed seeing?
You can set:
AdvStringGrid.Hovering := true;
Thank you for your reply. Setting hovering:=True seems to enable hot-tracking of the selected row. This is not what I want.
What I want to be able to do is change the font colour of cells in one column, to indicate that clicking will activate something (in this case, downloading of an invoice image). I already have the cursor change, but it's too subtle.
Is there a way to change the font colour of a particular column's cells (excluding fixed)?
This is an example of a possible implementation with a default TAdvStringGrid:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, AdvObj, BaseGrid, AdvGrid;
type
TForm1 = class(TForm)
AdvStringGrid1: TAdvStringGrid;
procedure FormCreate(Sender: TObject);
procedure AdvStringGrid1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure AdvStringGrid1GetCellColor(Sender: TObject; ARow, ACol: Integer;
AState: TGridDrawState; ABrush: TBrush; AFont: TFont);
private
{ Private declarations }
public
{ Public declarations }
MC,MR: integer;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.AdvStringGrid1GetCellColor(Sender: TObject; ARow,
ACol: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont);
begin
if (ACol = MC) and (ARow = MR) then
begin
AFont.Color := clRed;
end;
end;
procedure TForm1.AdvStringGrid1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
R,C: integer;
begin
advstringgrid1.MouseToCell(X,Y,C,R);
if (MC <> C) or (MR <> R) then
begin
MC := C;
MR := R;
AdvStringGrid1.Invalidate;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
advstringgrid1.RandomFill();
end;
end.