
im DF
1. Sind Zeilen die Rows vom StringGrid und nicht die Cols.
2. afaik geht das nur über eine Schleife, Dort verschiebst die die Zeilen nach der zu löschenden Zeile einfach nach "oben" und setzt zum Schluss RowCount um eins kleiner.
Hier ein bisschen Source aus einem meiner Programme:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20:
| procedure TfrmMain.Eintraglschen1Click(Sender: TObject); var cnt : Integer; begin if grdProtokoll.RowCount > 2 then begin if grdProtokoll.Row < grdProtokoll.RowCount - 1 then begin for cnt := grdProtokoll.Row+1 to grdProtokoll.RowCount - 1 do begin if cnt > 1 then begin grdProtokoll.Rows[cnt-1] := grdProtokoll.Rows[cnt]; end; end; end; grdProtokoll.RowCount := grdProtokoll.RowCount - 1; end else begin for cnt := 0 to grdProtokoll.ColCount - 1 do begin grdProtokoll.Cells[cnt,1] := ''; end; end; end; |
Dort sind, glaube ich, alle Sonderfälle abgehandelt. Zumindest funktioniert es bei mir ohne Fehler.