Board index » delphi » Getting selected row in TStringGrid.

Getting selected row in TStringGrid.


2003-08-08 01:34:44 AM
delphi259
How do I retrieve the row a user selects (clicks with left mouse button)
in a TStringGrid?
The OnSelectCell method gives me the *previously* selected row, not
the current row.
Sample code:
procedure TMyForm.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
var
iRow : Integer;
begin
iRow := StringGrid1.Row;
lblRow.Caption := Format('Row %d ', [iRow]);
lblRow.Refresh;
end;
The above code always retrieves and displays the *previously* selected
row, not the current row.
Thanks!
 
 

Re:Getting selected row in TStringGrid.

Dave,
StringGrid1.Selection options you have top, left, right, bottom. I use
StringGrid1.Selection.Top to get the row.
Wade
"Dave Norton" <XXXX@XXXXX.COM>writes
Quote
How do I retrieve the row a user selects (clicks with left mouse button)
in a TStringGrid?

The OnSelectCell method gives me the *previously* selected row, not
the current row.

Sample code:

procedure TMyForm.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
var
iRow : Integer;
begin
iRow := StringGrid1.Row;
lblRow.Caption := Format('Row %d ', [iRow]);
lblRow.Refresh;
end;

The above code always retrieves and displays the *previously* selected
row, not the current row.

Thanks!