Bonjour, je cherche a changer la couleur d'une cellule d'un tstringgrid lors d'un drag and drop: voici le code que j'ai fait:
ça marche, seulement, il y a des petits clignotements a cause du repaint, quelqu'un aurait - il une méthode plus propre a me proposer ?
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 procedure TForm1.gridDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin accept := true; painty := getr(y); grid.Repaint; end; function getr( y :integer):integer; var i,th : integer; begin th := form1.grid.top; for i := 0 to form1.grid.RowCount - 1 do begin th := th + form1.grid.RowHeights[i]; if (th > y) then begin result := i; break; end; end; end; procedure TForm1.gridDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); begin if (acol = 0) and (arow = painty) then begin grid.Canvas.Brush.Color:=clblack; painty :=-1; grid.Canvas.FillRect(rect); end; end;
Partager