In a TStringGrid, how do I:
1) get to know when a header is clicked?
2) select a cell, before my popup menu appears?
3) get to know exactly on which cell my mouse is? Also for the popup
menu?
Maybe a ClientDataSet would be easier with a DBGrid?
WBR
Sonnich
Most of is here:
procedure TForm1.StringGrid1DblClick(Sender: TObject);
var
P: TPoint;
iColumn, iRow: Longint;
begin
GetCursorPos(P);
with StringGrid1 do
begin
P := ScreenToClient(P);
MouseToCell(P.X, P.Y, iColumn, iRow);
end;
end;
but how do I get a single click from a header?
Sonnich
Set a global var MouseCell : TPoint;
procedure TMyForm.StringGrid1MouseDown(Sender: TObject; Button:
TMouseButton;
Shift: TShiftState; X, Y:
Integer);
var
ARow, ACol : integer;
begin
with StringGrid do begin
{get mouse cell indices}
MouseToCell(X, Y, ACol, ARow);
MouseCell := Point(ACol, ARow);
end;
Then you can get the coloumn & row from MouseCell in
StringGrid1Click() and do what you want if the MouseCell.Y is 0.
The OnClick event always comes after OnMouseDown.
Alan Lloyd
Thanks, it helped
>
> procedure TMyForm.StringGrid1MouseDown(Sender: TObject; Button:
> TMouseButton;
>
> Then you can get the coloumn & row from MouseCell in
> StringGrid1Click() and do what you want if the MouseCell.Y is 0.
>
> The OnClick event always comes after OnMouseDown.
>
> Alan Lloyd
Hi there
It should me Mouse-UP, so we copy the function from Click events - the
click is on recoqnised, when the mouse has left the component
WBR
Sonnich