Recent

Author Topic: [SOLVED] StringGrid insert row fails  (Read 1074 times)

VB_Lazarus

  • New member
  • *
  • Posts: 7
[SOLVED] StringGrid insert row fails
« on: March 21, 2020, 11:04:48 am »
Hello,

I have some problems with insert a row and then select it.
I want to duplicate a row.
I got the failure "insert out of range", although the selection is between the first and the last row.
Not outside.

Code: Pascal  [Select][+][-]
  1. procedure TfrmMain.Button_DuplizierenClick(Sender: TObject);
  2. var
  3.    ColumSelect : integer;
  4.    RowSelect : integer;
  5.    CellText : string;
  6. begin
  7.   RowSelect := StringGrid_ImportDatei.Row;
  8.   showmessage(IntToStr(StringGrid_ImportDatei.RowCount));
  9.  
  10.   StringGrid_ImportDatei.InsertColRow(false,RowSelect+1);
  11.   showmessage(IntToStr(StringGrid_ImportDatei.RowCount));
  12.  
  13.   for ColumSelect := 1 to StringGrid_ImportDatei.ColCount-1 do
  14.       begin
  15.          CellText:= StringGrid_ImportAnsicht.Cells[ColumSelect,RowSelect + 1];
  16.          StringGrid_ImportAnsicht.Cells[ColumSelect,RowSelect] := CellText;
  17.       end;
  18. end;                            
  19.  

What is wrong with this code.

Best regards
« Last Edit: March 21, 2020, 11:50:25 am by VB_Lazarus »

eljo

  • Sr. Member
  • ****
  • Posts: 468
Re: StringGrid insert row fails
« Reply #1 on: March 21, 2020, 11:31:00 am »
which grid raises the error? StringGrid_ImportAnsicht or StringGrid_ImportDatei?

VB_Lazarus

  • New member
  • *
  • Posts: 7
Re: StringGrid insert row fails
« Reply #2 on: March 21, 2020, 11:49:51 am »
Thank you, this was the answer.
I'm so stupid.
I didn't saw the difference.
I need only the StringGrid_ImportDatei.
I have to change the StringGrid_ImportAnsicht to StringGrid_ImportDatei and the code is correct.

Best regards.

 

TinyPortal © 2005-2018