salut
comment colore les lignes d'un DBGrid de façon alternative (blanc/grille/blanc/......)?
salut
comment colore les lignes d'un DBGrid de façon alternative (blanc/grille/blanc/......)?
Salut
Si ton DataSet gère le RecNo correctement, tu peux faire comme ceci:
En y pensant il y surement un exemple approchant dans la
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 uses Math; procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if gdSelected in State then Exit; with TDBGrid(Sender) do begin if Odd(DataSource.DataSet.RecNo) then Canvas.Brush.Color := clSilver else Canvas.Brush.Color := clWhite; DefaultDrawColumnCell(Rect, Datacol, Column, State); end; end;
@+ Claudius
tu peut voir ca
http://www.developpez.net/forums/sho...d.php?t=328039
salut
tu doit definir un CHAMPS IDENT corespondant au numero de ligne
ramener
selon les base de donnée il existe des instruction pour definir un champs incrementale
une fois ce champs defini il ne reste plus qu'a redessiner le dbgrid
@+ Phil
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); var DataSet: TDataSet; begin with (Sender as TDBGrid) do begin DataSet := Column.Field.DataSet; if (DataSet.FieldByName('IDENT').Asinteger mod 2) = 0 then begin Canvas.Brush.Color := clWhite; Canvas.Font.Color := clgray; end else begin Canvas.Brush.Color := clgray; Canvas.Font.Color := clWhite; end DefaultDrawColumnCell(Rect, DataCol, Column, State) end end;
PS arg 3 reponses dans l'intervalle je vraiment pas assez rapide
salut ,
tu peut utiliser le composant JvDBUltimGrid de la bibliotheque JVCL.
il sufit de rensiengner la propriete AlternateRowColor !!!!
Partager