gegila
Messages postés6Date d'inscriptionvendredi 20 août 2004StatutMembreDernière intervention 7 juin 2005
-
8 avril 2005 à 17:43
gegila
Messages postés6Date d'inscriptionvendredi 20 août 2004StatutMembreDernière intervention 7 juin 2005
-
9 avril 2005 à 17:22
Salut à tous,
Comment limiter la saisie de caractères dans une des colonnes d'un stringrid, comme dans un edit.
DRJEROME
Messages postés436Date d'inscriptionjeudi 9 janvier 2003StatutMembreDernière intervention 5 février 2015 9 avril 2005 à 08:45
Exemple pour la colonne n°1 (càd la 2° colonne) avec un maximum de 5 caractères (tu mets une autre valeur si tu veux en changeant les "5" par le nombre de caractères que tu veux) :
<HR>
procedure TForm1.StringGrid1SetEditText(Sender: TObject; ACol,
ARow: Integer; const Value: String);
begin
if ACol=1 then if Length(StringGrid1.Cells[ACol,ARow])>5 then StringGrid1.Cells[ACol,ARow]:=copy(StringGrid1.Cells[ACol,ARow],1,5);
end;
<HR>
ou alors :
<HR>
procedure TForm1.StringGrid1SetEditText(Sender: TObject; ACol,
ARow: Integer; const Value: String);
begin
if ACol=1 then if Length(StringGrid1.Cells[ACol,ARow])>5 then
begin
showmessage('Pas plus de 5 caractères SVP !');
StringGrid1.Cells[ACol,ARow]:=copy(StringGrid1.Cells[ACol,ARow],1,5);
end;
end;
<HR>
il y a sans doute mieux comme solution...désolé, c'est tout ce que j'ai à te proposer...