Jesus Reyes ha scritto:
 --- Jesus Reyes <[EMAIL PROTECTED]> escribió:
 --- Tiziano-tele2 <[EMAIL PROTECTED]> escribió:


It works this way by design, to see some info about it see:

http://wiki.lazarus.freepascal.org/index.php/Grids_Reference_Page#property_Rows.5Bindex:_Integer.5D:_TStrings_read_GetRows_write_SetRows.3B
Regards.

Jesus Reyes A.


I updated wiki info with the not working example.

ok, I see. It means low compatibility with Delphi... There are some advantages?

If you wish, you could add this bunch of code to overcome this problem:

  procedure sg_setXXXYYYtext(sg: tstringgrid; theX: integer; thetext: string;
                             Xisforrows, Yisfortext: boolean);
  { set a tstringgrid row/col values with a comma delimited/crlf text }
  var tmplist: tstringlist;
  begin
    with sg do
      begin
        if Xisforrows
           then tmplist:= tstringlist(rows[theX])
           else tmplist:= tstringlist(cols[theX]);
        if assigned(tmplist)
           then try
                  if Yisfortext
                    then tmplist.text:= thetext
                    else tmplist.commatext:= thetext;
                  if Xisforrows
                     then sg.rows[theX]:= tmplist
                     else sg.cols[theX]:= tmplist;
                finally
                  tmplist.free;
                end;
      end;
  end;

  function sg_getXXXYYYtext(sg: tstringgrid; theX: integer;
                            Xisforrows, Yisfortext: boolean): string;
  { get the tstringgrid row values as a comma delimited text }
  var tmplist: tstringlist;
  begin
    with sg do
      begin
        if Xisforrows
           then tmplist:= tstringlist(rows[theX])
           else tmplist:= tstringlist(cols[theX]);

        if assigned(tmplist)
           then try
                if Yisfortext
                  then result:= tmplist.text
                  else result:= tmplist.commatext;
                finally
                  tmplist.free;
                end;
      end;
  end;

  procedure sg_setrowcommatext(sg: tstringgrid; therow: integer; thetext: 
string);
  { set a tstringgrid row values with a comma delimited text }
  begin
    sg_setXXXYYYtext(sg, therow, thetext, true, false);
  end;

  procedure sg_setrowtext(sg: tstringgrid; therow: integer; thetext: string);
  { set a tstringgrid row values with a crlf text }
  begin
    sg_setXXXYYYtext(sg, therow, thetext, true, true);
  end;

  procedure sg_setcolcommatext(sg: tstringgrid; thecol: integer; thetext: 
string);
  { set a tstringgrid col values with a comma delimited text }
  begin
    sg_setXXXYYYtext(sg, thecol, thetext, false, false);
  end;

  procedure sg_setcoltext(sg: tstringgrid; thecol: integer; thetext: string);
  { set a tstringgrid col values with a crlf text }
  begin
    sg_setXXXYYYtext(sg, thecol, thetext, false, true);
  end;

  function sg_getrowcommatext(sg: tstringgrid; therow: integer): string;
  { get the tstringgrid row values as a comma delimited text }
  begin
    result:= sg_getXXXYYYtext(sg, therow, true, false);
  end;

  function sg_getrowtext(sg: tstringgrid; therow: integer): string;
  { get the tstringgrid row values as a crlf text }
  begin
    result:= sg_getXXXYYYtext(sg, therow, true, true);
  end;

  function sg_getcolcommatext(sg: tstringgrid; thecol: integer): string;
  { get the tstringgrid col values as a comma delimited text }
  begin
    result:= sg_getXXXYYYtext(sg, thecol, false, false);
  end;

  function sg_getcoltext(sg: tstringgrid; thecol: integer): string;
  { get the tstringgrid col values as a crlf text }
  begin
    result:= sg_getXXXYYYtext(sg, thecol, false, true);
  end;

thanks
tiziano

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to