PDA

View Full Version : چگونگی انجام عمل Drag and Drop



Hafez
دوشنبه 29 فروردین 1384, 15:22 عصر
میخوام مثلا بین دو edit متن اونا رو با عمل drag جا به جا کنم . از edit 1 به edit 2 چکار کنم ؟
یا مثلا یک تصویر رو روی یک فرم با عمل drag جابه جا کنم .
بطوری که تصویر در جای خاصی از فرم ثابت شود .
ممنون میشم اگه جواب منو بدید

Delphi-Clinic
دوشنبه 29 فروردین 1384, 15:42 عصر
سلام

یک مثال تر وتمیز از راهنمای دلفی عزیز :



This code comes from an application that contains a list box and three labels, each with a different font and color. The DragMode property for each of the labels is dmAutomatic. The user can select a label and drag it to a list box and drop it. When the label is dropped, the items in the list box assume the color and font of the dropped label.
This OnDragOver event handler permits the list box to accept a dropped label:

procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);

begin
Accept := Source is TLabel;

end;

This OnDragDrop event handler implements the drop behavior.

procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer);

begin
if (Sender is TListBox) and (Source is TLabel) then
begin
with Sender as TListBox do
begin
Font := (Source as TLabel).Font;
Color := (Source as TLabel).Color;
end;
end;
end;


روز خوش :)

ashkan2005
پنج شنبه 19 بهمن 1385, 20:34 عصر
با سلام خدمت شما عزیزان
می خواستم ببینم که برای اینکه یک item از یک listbox رو توسط ماوس به یک listbox دیگه dragdrop کنم باید چیکار کنم .:متفکر:

babak869
پنج شنبه 19 بهمن 1385, 21:57 عصر
یه سربه این آدرس بزن یه نمونه آپلود کردم . البته در سایت هم هست اما زحمت جستجو با خودت

http;//www.Delphi-Magic.com/source.php

موفق باشید

vcldeveloper
جمعه 20 بهمن 1385, 09:03 صبح
درباره Drag کردن قبلا در سایت بحث شده:
http://www.barnamenevis.org/forum/showthread.php?t=42304&highlight=Drag
http://www.barnamenevis.org/forum/showthread.php?t=49351&highlight=Drag
http://www.barnamenevis.org/forum/showthread.php?t=631&highlight=Drag
http://www.barnamenevis.org/forum/showthread.php?t=21549&highlight=Drag
و...