Réponse acceptée !
Hello,
Voici une fonction qui te permet de détruire la ligne désirée d'un stringgrid :
- Tu lui passes la ligne
- Puis ton stringgrid
- La fonction te retournera True si tout c'est bien passé ou false en cas d'erreur
function DeleteRowStringGrid(Row : Integer;
var StrGrid : TStringGrid) : Boolean;
var
I,J : Integer;
List : Array of TStringList;
begin
Result := True;
Try
SetLength(List,StrGrid.ColCount);
{Dimensionnement du tableau dynamique}
For I:=0
to High(List)
do List[I] := TStringList.Create;
{Création des StringList}
Try
For I:=0
to High(List)
do
begin
{Récupération des données du stringrid dans les tstringlist}
For J:=0
to StrGrid.RowCount-1
do
List[I].Add(StrGrid.Cells[I,J]);
end;
For I:=0 to High(List) do List[I].Delete(Row);
{Destruction de la ligne}
{On enleve une ligne au stringrid}
StrGrid.RowCount := StrGrid.RowCount - 1;
For I:=0
to High(List)
do
begin
{remet les résultats dans le stringrid}
For J:=0
to StrGrid.RowCount-1
do
StrGrid.Cells[I,J] := List[I].Strings[J];
end;
Finally
For I:=0
to High(List)
do List[I].Free;
{Libération de la mémoire}
end;
Except
Result := False;
end;
end;Bonne prog,
JMP77.
N'oubliez pas de cliquer sur réponse acceptée.