Recent

Author Topic: Selecting the first row?  (Read 1584 times)

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Selecting the first row?
« on: May 25, 2018, 06:06:38 pm »
I have a form with a TStringGrid on it.
It is filled with data. (see attachment)


How do i automatically select the first row of this TStringGrid?

You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Selecting the first row?
« Reply #1 on: May 25, 2018, 08:15:22 pm »
Setting the Row property does it:
Code: Pascal  [Select][+][-]
  1. StringGrid1.Row := StringGrid1.FixedRows;

FixedRows is the number of the fixed rows and, as the row indexes are 0-based (including fixed rows), the first non-fixed row has the index which always equals to FixedRows (in your example it is 1).
« Last Edit: May 25, 2018, 08:18:54 pm by Zoran »

wp

  • Hero Member
  • *****
  • Posts: 11854
Re: Selecting the first row?
« Reply #2 on: May 25, 2018, 08:47:12 pm »
In addition, you must activate Option goRowSelect to select the entire row.

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Selecting the first row?
« Reply #3 on: May 25, 2018, 10:33:51 pm »
In addition, you must activate Option goRowSelect to select the entire row.
Also, goSelectionActive might be interesting for you.

 

TinyPortal © 2005-2018