Re:What is the best solution
In article <N7Lda.111627$zo2.2933...@news2.tin.it>, "Franco Jommi"
Quote
<franco.jom...@tin.it> writes:
>I had thought to a TStringGrid, but it looked somewhat too complicated
If you're looking to decide which column of a stringgrid was clicked, there is
a simple technique which overcomes the problem of not getting the mouse cell in
the OnClick or OnDoubleClick handler. This stores the mouse X & Y in a global
variable in OnMouseDown, then accesses those in the OnDoubleClick event handler
and uses MouseToCell. This relies on the fact that a mouse-down notification is
always sent before a click or double-click notification. The code is as follows
...
var
MouseX, MouseY : integer;
procedure TForm1.StringGrid1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
{store mouse X & Y}
MouseX := X;
MouseY := Y;
end;
procedure TForm1.StringGrid1DblClick(Sender: TObject);
var
ACol, ARow : integer;
begin
{calculate cell}
StringGrid1.MouseToCell(MouseX, MouseY, ACol, ARow);
{test for menu row}
if ARow = 1 then
ShowMessage('You Dbl-Clicked Column ' + IntToStr(ACol));
end;
Alan Loyd
alangll...@aol.com