Recent

Author Topic: select a cell of stringgrid  (Read 17877 times)

marquessbr

  • Jr. Member
  • **
  • Posts: 56
select a cell of stringgrid
« on: July 21, 2009, 03:19:11 pm »
Hi all of list!
I need to select a cell of a stringgrid with a text, e.g: I need with my app to find in all cells of a stringgrid for the text typed in a tedit field.

have a whay to do this in lazarus?

peace!

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1934
Re: select a cell of stringgrid
« Reply #1 on: July 21, 2009, 04:48:31 pm »
Is your problem to select a cell or to find a cell?
Afaik you can only select one cell at a time with TStringGrid.

cpalx

  • Hero Member
  • *****
  • Posts: 754
Re: select a cell of stringgrid
« Reply #2 on: July 22, 2009, 02:26:36 am »
you must search cell by cell. It is not dificult

marquessbr

  • Jr. Member
  • **
  • Posts: 56
Re: select a cell of stringgrid
« Reply #3 on: July 22, 2009, 01:37:28 pm »
Hi theo, my pproblem is just find a text in a cell and then select this cell ...
Thanks, for reply.

Hi cpalx!
shiet, my grid is so big, this will take several time.
thanks!

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1934
Re: select a cell of stringgrid
« Reply #4 on: July 22, 2009, 02:27:04 pm »
I don't know what exactly you don't understand.

Sth. like this?

Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
var i,pos:integer;
begin
  For i:=0 to StringGrid1.RowCount-1 do
     begin
     pos:=StringGrid1.Rows[i].IndexOf(Edit1.text);
       if pos > -1 then
         begin
          StringGrid1.Row:=i;
          StringGrid1.Col:=pos;
          StringGrid1.SetFocus;
          break;
         end;
     end;
end;       

marquessbr

  • Jr. Member
  • **
  • Posts: 56
Re: select a cell of stringgrid
« Reply #5 on: July 22, 2009, 05:07:15 pm »
thanks, theo!
For now, I beleave with this solve my problem.

peace

 

TinyPortal © 2005-2018