Board index » delphi » How to highlight current row or cell in a StringGrid

How to highlight current row or cell in a StringGrid

My StringGrid has 2 columns and 100 rows with vertical scroll bars.

At start-up, the first row is the current row..

The operator enters a value in the first column.  
The  program inserts data into the second column and
then makes the next row the current row.  

My question is how to make the operator aware of which row is the
current row.  

My preference would be by making the color of the current row
different to the other rows.

Any suggestions on how to do this with either a StringGrid or some
other way would be massively appreciated.

Please reply by email to jr...@extro.ucc.su.oz.au

John Ryan

 

Re:How to highlight current row or cell in a StringGrid


Quote
jr...@extro.ucc.su.oz.au (John Ryan) wrote:
>My StringGrid has 2 columns and 100 rows with vertical scroll bars.
>At start-up, the first row is the current row..
>Any suggestions on how to do this with either a StringGrid or some
>other way would be massively appreciated.
>John Ryan

You can set the Selection property of a String Grid which will move
and place the blue selection box/background. To show an entire row as
selected, go to the String Grid Options property - set Multiselect to
False, set RowSelection (I think those property names are close) to
true.

In order to programatically set the selection do something like the
following -

var
  sr : TStringGridRect;

begin
  sr := StringGrid1.Selection;

  sr.Top := RowNumberToSelect;
  sr.Bottom := sr.Top;

  StringGrid1.Selection := sr;

Hope this helps.
Barry.

/---------------------------------------------------------------\
| Check out CanalRun's WWW page http://www.vcomm.net/~canalrun/ |
| Education, Investment, Personal Productivity Shareware.       |
\---------------------------------------------------------------/

Other Threads