Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Set a cell selection in TStringGrid

3,400 views
Skip to first unread message

Phillip Garnes

unread,
Oct 23, 1998, 3:00:00 AM10/23/98
to
How do I do it programatically? Or, for that matter, how do I determine
which cell is the selected one? BTW, I tried to understand the
explanation for TCustomGrid.Selection in the on-line Help but I'm left
puzzled. What's a TGridCoord ? Can someone give an example?

Phil Garnes


Phillip Garnes

unread,
Oct 23, 1998, 3:00:00 AM10/23/98
to
Ken Halland wrote in message <361C7F...@unisa.ac.za>...
>Can anyone tell me how to set the focus on a particular cell of a
>StringGrid component?


Just set the StringGrid's Row and Col properties and call
StringGrid.SetFocus.

--
Wayne Niddery - WinWright Consulting
Delphi, C++Builder, JBuilder, InterDev -- Amazon.com Associate
at http://home.ican.net/~wniddery/RADBooks.html
--- CUT ---

.... another answer from "Lutz Lohnstein" <LLohn...@KHK.de>

Hi Ken, try this

to select Cell[2,3] you have to set the selection-property of the grid.
MyGrid.Selection := tGridRect(Rect(2,3,2,3));

hope this helps

Phillip Garnes wrote:

Rick Rogers (TeamB)

unread,
Oct 23, 1998, 3:00:00 AM10/23/98
to
On Fri, 23 Oct 1998 16:56:04 -0400, Phillip Garnes
<pga...@earthlink.net> wrote:

> How do I do it programatically?

If you only need to do single cell selection:

StringGrid.Col := 2;
StringGrid.Row := 1;

For multiple cell selection:

var
GridRect: TGridRect;
begin
GridRect.Top := 1;
GridRect.Left := 1;
GridRect.Right := 3;
GridRect.Bottom := 2;
StringGrid1.Selection := GridRect;
end;

--
Rick Rogers (TeamB) | Fenestra Technologies
http://www.fenestra.com/

0 new messages