Salut,
Ben tout est dans le titrev :-)
Je cherche à drap/droper des éléments d'un DBGrid !
Merci de votre aide !
Mickael
Salut,
Ben tout est dans le titrev :-)
Je cherche à drap/droper des éléments d'un DBGrid !
Merci de votre aide !
Mickael
![]()
....car déjà abordé dans ce forum![]()
re,
Disons que je me suis trompé.. c'est pas un DBGrid, mais un StringGrid !
J'ai pas trouvé grand chose sur le forum, par contre ceci sur Google:
http://www.festra.com/wwwboard/messages/10053.html
Le problème viens du fait que ca marche, mais il ne "bouge" que la cellule qu'on à cliqué, et moi je voudrais bouger toute la ligne ...
GoRowSelected = True
Quelqu'un à ca dans le tirroir ?
Merci
Ca c'est le drag.Envoyé par mickaelmediaprod
Le drop, tu le fais où ?
Beuuuuuh ???
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 implementation {$R *.DFM} var SourceCol, SourceRow: integer; procedure TForm1.FormCreate(Sender: TObject); begin { Set DragMode to Manual, to control entire drag & drop by code } SG.DragMode := dmManual; { For testing purposes, fill a few cells } SG.Cells[2, 2] := 'A'; SG.Cells[3, 2] := 'B'; SG.Cells[4, 2] := 'C'; end; procedure TForm1.SGMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: integer); begin { Convert mouse coordinates X, Y to to StringGrid related col and row numbers } SG.MouseToCell(X, Y, SourceCol, SourceRow); { Allow dragging only if an acceptable cell was clicked (cell beyond the fixed column and row) } if (SourceCol > 0) and (SourceRow > 0) then { Begin dragging after mouse has moved 4 pixels } SG.BeginDrag(False, 4); end; procedure TForm1.SGDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); var CurrentCol, CurrentRow: integer; begin SG.MouseToCell(X, Y, CurrentCol, CurrentRow); // convert mouse coord. { Accept dragged stuff only if it came from StringGrid and the mouse is now over an acceptable region } Accept := (Sender = Source) and (CurrentCol > 0) and (CurrentRow > 0); end; procedure TForm1.SGDragDrop(Sender, Source: TObject; X, Y: Integer); var DestCol, DestRow: Integer; begin SG.MouseToCell(X, Y, DestCol, DestRow); // convert mouse coord. { Move contents from source to destination } SG.Cells[DestCol, DestRow] := SG.Cells[SourceCol, SourceRow]; if (SourceCol <> DestCol) or (SourceRow <> DestRow) then SG.Cells[SourceCol, SourceRow] := ''; end;
sur les newsgroup:
http://groups.google.be/group/alt.co...b8b6213e960b8e
C'est tout ce que j'ai trouvé.. bouger une cellule ou une collone , mais jamais une ligne !! help :s
SAlut
Je connais pas trop cette outils la, mais as tu fais des essais en changeant des elements du code que tu as recuperé? Par exemple dans TForm1.SGDragDrop, si tu changes
Par un truc du genre
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 SG.Cells[DestCol, DestRow] := SG.Cells[SourceCol, SourceRow]; if (SourceCol <> DestCol) or (SourceRow <> DestRow) then SG.Cells[SourceCol, SourceRow] := '';
Je n'est pas testé mais ca me semblerai correct.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 SG.Rows[DestRow] := SG.Rows[SourceRow]; if SourceRow <> DestRow then SG.Rows[SourceRow] := '';
A plus![]()
MagicQwaz := Harry Potter la baguette en moins
Le monde dans lequel on vit
Ma page perso DVP
Dernier et SeulTutoriel : VBA & Internet Explorer
Dernière contribution : Lien Tableau Structuré et UserForm
L'utilisation de l’éditeur de message
Partager