_AciD_
Messages postés6Date d'inscriptiondimanche 28 septembre 2003StatutMembreDernière intervention 4 octobre 2003
-
1 oct. 2003 à 19:43
_AciD_
Messages postés6Date d'inscriptiondimanche 28 septembre 2003StatutMembreDernière intervention 4 octobre 2003
-
4 oct. 2003 à 22:06
Voila j'ai un probleme avec ma grille je voudrais supprimer une ligne et que automatiquement les lignes ki suivent celle effacée remontent.... voila je ne parviens pas a trouver si kelkun peut m'envoyer le code source ce serait gentil de sa part. merci d'avance a très bientot
cs_RMD
Messages postés84Date d'inscriptionmercredi 25 septembre 2002StatutMembreDernière intervention21 mai 2004 2 oct. 2003 à 09:23
Bonjour,
Si tu parles d'un StringGrid voici une solution que j'avais trouvé je ne sais plus où :
Le type TCustomGrid a une méthode DeleteRow, mais cette méthode n'est pas dans la section public mais protected.
Toutefois, TStringGrid successeur de TCustomGrid peu voir cette méthode.
type
THackStringGrid = class(TStringGrid);
procedure DeleteRow(TonStringGrid: TStringGrid; ARow: Integer);
begin
with THackStringGrid(TonStringGrid) do
DeleteRow(ARow);
end;
_AciD_
Messages postés6Date d'inscriptiondimanche 28 septembre 2003StatutMembreDernière intervention 4 octobre 2003 2 oct. 2003 à 18:28
Merci cependant voila j'ai un gros probleme je vous donne mon code je sais qu'il est loin d'etre bon mais je débute seulement donc si vous pouviez m'aider ....
J'ai 2 problemes le 1er c'est ke kan je supprime ma ligne après je ne peux pu rentrer aucune donnée et le second c'est que kan je supprime ma ligne le montant n'est pas soustrait a mon montant global merci d'avance :)
var
Form1: TForm1;i:integer;Montant:Real;j,k:integer;q,p:Real;
implementation
{$R *.dfm}
procedure TForm1.TelKeyPress(Sender: TObject; var Key: Char);
begin
If key In ['0'..'9','-','.','+',',','_',#8] Then exit else key:=#18;
end;
procedure TForm1.QuantiteKeyPress(Sender: TObject; var Key: Char);
begin
If key In ['0'..'9',#8] Then exit else key:=#18;
end;
procedure TForm1.PrixKeyPress(Sender: TObject; var Key: Char);
begin
If key In ['0'..'9',#8] Then exit else key:=#18;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
i:=0;montant:=0;
StringGrid1.cells[0,0]:='Reference' ;
StringGrid1.cells[1,0]:='Libelle' ;
StringGrid1.cells[2,0]:='Quantite' ;
StringGrid1.cells[3,0]:='Prix' ;
StringGrid1.cells[4,0]:='Montant' ;
end;
procedure TForm1.CodKeyPress(Sender: TObject; var Key: Char);
begin
If key In ['0'..'9',#8] Then exit else key:=#18;
end;
procedure TForm1.OKClick(Sender: TObject);
var q,p:Real;j:integer ;
begin
Val(quantite.Text,q,j); Val (prix.Text,p,j);
Inc(i);
begin
StringGrid1.cells[0,i]:=Refe.Text;
StringGrid1.cells[1,i]:=Libelle.Text;
StringGrid1.cells[2,i]:=Quantite.Text;
StringGrid1.cells[3,i]:=Prix.Text;
StringGrid1.cells[4,i]:=FormatFloat('#######0.00€',q*p);
montant:=montant+q*p;
Result.Caption:=floattostr(montant);
end;
Refe.clear;Libelle.Clear;Quantite.Clear;Prix.Clear;
end;
procedure TForm1.DelClick(Sender: TObject);
begin
for i := StringGrid1.row to StringGrid1.RowCount - 2 do
StringGrid1.Rows[i] := StringGrid1.Rows[i + 1];
StringGrid1.RowCount := StringGrid1.RowCount - 1;
end;
begin
if i=0 then
exit;
End.
cs_RMD
Messages postés84Date d'inscriptionmercredi 25 septembre 2002StatutMembreDernière intervention21 mai 2004 3 oct. 2003 à 16:37
Bonjour,
Si tu supprimes l'unique ligne du StringGrid, évidement tu ne peux y réécrire.
3 solutions :
1 Soit tu effaces les cellules :
StringGrid1.cells[0,i]:='';
etc.
2 Soit tu ajoutes une ligne après avoir détruit la précédente :
StringGrid1.RowCount:=StringGrid1.RowCount+1;
_AciD_
Messages postés6Date d'inscriptiondimanche 28 septembre 2003StatutMembreDernière intervention 4 octobre 2003 3 oct. 2003 à 17:11
jcrois ke c'est la solution 3 :)
StringGrid1.RowCount:=StringGrid1.RowCount+1 ca sert a rien ca sauf me rajjouté une ligne or j'en ai pas besoin jve juste pouvoir réécrire après avoir supprimé ma ligne : )))))))
merci ke meme et merci d'avance :)
Vous n’avez pas trouvé la réponse que vous recherchez ?
_AciD_
Messages postés6Date d'inscriptiondimanche 28 septembre 2003StatutMembreDernière intervention 4 octobre 2003 3 oct. 2003 à 17:43
ben en faite j'ai trouvé comment réécrire seulement voila ca me réécri en laissant une ligne d'espace
comme si j'avai laissé une ligne blanche ....je vois pas ou est le pb :(
_AciD_
Messages postés6Date d'inscriptiondimanche 28 septembre 2003StatutMembreDernière intervention 4 octobre 2003 3 oct. 2003 à 18:10
begin
dec(i);
for i := StringGrid1.row to StringGrid1.RowCount - 2 do
StringGrid1.Rows[i] := StringGrid1.Rows[i + 1];
StringGrid1.RowCount := StringGrid1.RowCount - 1;
end;
un truc du genre koi ? jte remercie jvé travailler a bientot j'espere encore merci je testerais cela en rentrant ce soir merci :)
cs_RMD
Messages postés84Date d'inscriptionmercredi 25 septembre 2002StatutMembreDernière intervention21 mai 2004 3 oct. 2003 à 18:25
Il vaudrait mieux faire
for i := StringGrid1.row to StringGrid1.RowCount - 2 do
StringGrid1.Rows[i] := StringGrid1.Rows[i + 1];
StringGrid1.RowCount := StringGrid1.RowCount - 1;
end;
Dec(i);
sinon tu vas effacer la mauvaise ligne !
_AciD_
Messages postés6Date d'inscriptiondimanche 28 septembre 2003StatutMembreDernière intervention 4 octobre 2003 4 oct. 2003 à 22:06
vé thanks ca fonctionne mais maintenant j'ai une erreur pour mon compte ki ne se soustrait pas kan je supprime une ligne j'ai pourtant bien mis mon montant:=montant-q*p mais ca amrche pas je vois aps le pb si on pouvais me donner le code a tapper ca serait cool merci :) a bientot