Einzelnen Beitrag anzeigen

lucy

Registriert seit: 25. Okt 2017
63 Beiträge
 
Delphi XE7 Starter
 
#1

StringGrid Zeile hinzufügen

  Alt 31. Okt 2022, 07:30
Hallo,
habe hier im Forum schon gesucht, bin aber leider noch nicht fündig geworden.

Zurzeit wird die neue Zeile (im StringGrid) unten angehängt.
Wie kann man die aktuelle Zeile oben im StringGrid einfügen?
So das die älteren Datensätze nach unten geschoben werden.

Code:
procedure TForm1.ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
 var
     MSG, MSG1 : String;
             sl: TStrings;
    i, zaehler : Integer;
 begin
  MSG := Socket.ReceiveText;

  sl := TStringList.Create;
  sl.delimiter := ':';
  sl.DelimitedText := MSG;
   if sl.Strings[0] = 'test' then begin
    Memo1.Lines.Delete(0);
     end else begin
       MSG1 := sl.Strings[0] + ' | ' + sl.Strings[1] + ' | ' + sl.Strings[2] + ' | ' + sl.Strings[3] + ' | ' + sl.Strings[4];
       Memo3.Lines.Add('Status: ' + datetostr(date) + ' | ' + timetostr(time) + ' | ' + Socket.RemoteAddress + ' | ' + 'OnClientRead | ' + MSG1);
       
        i := StringGrid1.RowCount;
         StringGrid1.RowCount := i +1;

         StringGrid1.Cells [0, i] := '';
         StringGrid1.Cells [1, i] := '';
         StringGrid1.Cells [2, i] := IntToStr(zaehler);
         StringGrid1.Cells [3, i] := FormatDateTime ('dd:mm:yyyy', Now);
         StringGrid1.Cells [4, i] := FormatDateTime ('hh:nn:ss', Now);
         StringGrid1.Cells [5, i] := (sl.Strings[3]);

         StringGrid1.ColWidths[0] := 25;
         StringGrid1.ColWidths[1] := 70;
         StringGrid1.ColWidths[2] := 70;
         StringGrid1.ColWidths[3] := 70;
         StringGrid1.ColWidths[4] := 70;
         StringGrid1.ColWidths[5] := 125;
         StringGrid1.ColWidths[6] := 5000;

         StringGrid1.Cells [0,0] := '';
         StringGrid1.Cells [1,0] := '';
         StringGrid1.Cells [2,0] := 'TICKET';
         StringGrid1.Cells [3,0] := 'DATUM';
         StringGrid1.Cells [4,0] := 'ZEIT';
         StringGrid1.Cells [5,0] := 'ID';
         StringGrid1.Cells [6,0] := 'BESCHREIBUNG';
  end;
 end;
  Mit Zitat antworten Zitat