Doublons

yassou2004 Messages postés 2 Date d'inscription lundi 29 novembre 2004 Statut Membre Dernière intervention 1 juin 2007 - 1 juin 2007 à 15:25
yassou2004 Messages postés 2 Date d'inscription lundi 29 novembre 2004 Statut Membre Dernière intervention 1 juin 2007 - 1 juin 2007 à 20:29
Bonjour a tous et à toutes

voila g une stringgrid rempli avec des données,

et j'aimerais savoir comment mettre les doublons en évidence(no pas les supprimer)?

merci d'avance

2 réponses

dominique.stock Messages postés 436 Date d'inscription vendredi 7 novembre 2003 Statut Membre Dernière intervention 8 octobre 2008 7
1 juin 2007 à 16:14
Bonjour,
Tu n'as qu'à colorier les cellules où il y a un doublon ....

Dom
0
yassou2004 Messages postés 2 Date d'inscription lundi 29 novembre 2004 Statut Membre Dernière intervention 1 juin 2007
1 juin 2007 à 20:29
voila g fait ce petit code ms ca marche pas trop:

procedure TForm2.Button1Click(Sender: TObject);
begin
l:=StringGrid1.RowCount-1;
setlength(tcol,l);
for i:= 0 to l-1 do
    begin
        Tcol[i]:=false;
    end;
for i:=0 to StringGrid1.RowCount-1 do
begin
    sDoublon:=StringGrid1.Cells[1,i];
    for j:=0 to StringGrid1.RowCount-1 do
    begin
        if ((sDoublon = StringGrid1.Cells[1,j]) and (i<>j))then
        begin
            TCol[i]:= true;
        end;
    end;
end;
end;

procedure TForm2.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
  var k:integer;
begin
 With Sender As TStringGrid Do With Canvas Do
  Begin
    If gdFixed in State
      Then Brush.Color := clBtnFace
      Else If gdSelected In State
        Then Brush.Color := clNavy
        Else If Odd(ARow)
          Then Brush.Color := $FFE0FF
          Else Brush.Color := $FFFFE0;
    FillRect(Rect);
    If gdSelected In State
      Then Font.Color:=clWhite
      Else Font.Color:=clBlack;
    for k:= 0 to l-1 do
    begin
        if Tcol[k]=true then font.Color:=clRed;
    end;
    TextOut(Rect.Left,Rect.Top,Cells[ACol,ARow]);
  End;
end;
0
Rejoignez-nous