bonjour, j'ai fait ca : (grace à la FAQ de ce superbe site)
Mais et oui il y a un mais
lors de l'affichage il me mets bien les en tete dans les fixedrows mais aussi dans la premiere ligne
c'est genant....
Si quelq'un à une pitie idée... parce que moi
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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 Procedure TF_RecCLient.GrilleAffiche; var ligne, colonne, i: Integer; MaxWidth, //Largeur maximale de la colonne MinWidth, //Largeur minimale de la colonne CurrentWidth: integer; //Largeur actuelle FieldSize: integer; //Taille du champ begin MyStringGrid.Visible := true; with DM.IBQuery do begin Open; // ouvre la requete MyStringGrid.RowCount := 2; //2 lignes MyStringGrid.ColCount := FieldCount; // autant de colonnes que d'enregistrements { Remplissage des entêtes } for colonne := 0 to MyStringGrid.ColCount - 1 do MyStringGrid.Cells[colonne, 0] := Fields[colonne].DisplayName; { Données } First; ligne := 1; //1ere ligne while not Eof do begin MyStringGrid.RowCount := MyStringGrid.RowCount + 1; for colonne := 0 to MyStringGrid.ColCount-1 do MyStringGrid.Cells[colonne, ligne] := Fields[colonne].AsString; Next; Inc(ligne); //if not Eof then end; //while end; //whith with MyStringGrid do begin for colonne := 0 to MyStringGrid.ColCount-1 do begin MyStringGrid.Row := 0; MaxWidth := Canvas.TextWidth(MyStringGrid.Cells[colonne, 0]) + 5; MinWidth := 0; ligne := 0; while ligne < MyStringGrid.RowCount do begin //Déterminer la largeur en pixels du contenu de l'enregistrement lu FieldSize := Canvas.TextWidth(MyStringGrid.Cells[colonne,ligne])+5; //Réajuster la largeur maximale ? if MaxWidth < FieldSize then MaxWidth := FieldSize; //Réajuster la largeur minimale ? if MinWidth > FieldSize then MinWidth := FieldSize; inc(ligne) end; //while //Largeur de la colonne cliquée CurrentWidth := MyStringGrid.ColWidths[Colonne]; if CurrentWidth <> MaxWidth then CurrentWidth := MaxWidth; if CurrentWidth < MinWidth then CurrentWidth := MinWidth; //Affectation de la nouvelle largeur à la colonne ColWidths[colonne] := CurrentWidth; end; // for end; //with close; end; // procedure![]()
![]()
PS : j'ai essayé :+
![]()
Partager