
November 21st, 2012, 06:03 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 1
Time spent in forums: 18 m 13 sec
Reputation Power: 0
|
|
|
Firemonkey TListBox drag and drop problem
Hello,
I have a ListBox that I need to contain list of files. I need functionality for user to select one or multiple files and than to drag files and drop them on the ListBox. When files are dropped, Items are created with a file names. This works fine, but the problem is, when I drag over and drop file on a dynamically created Item inside ListBox, file icon remains drawn on a desktop as a "ghost". Please check following screenshots for more details:
http://www.razno.org/uploads/1.jpg
http://www.razno.org/uploads/2.jpg
This "sample.txt" icon remains on desktop. Can anyone tell me what am I doing wrong?
This is the code used for drag and drop operation:
Code:
procedure TTestForm.FileListBoxDragDrop(Sender: TObject; const Data: TDragObject;
const Point: TPointF);
var
i: integer;
item: TListBoxItem;
begin
try
FileListBox.BeginUpdate;
for i := Low(Data.Files) to High(Data.Files) do begin
Item := TListBoxItem.Create(Self);
Item.Text := ExtractFileName(Data.Files[i]);
Item.Parent := FileListBox;
end;
finally
FileListBox.EndUpdate;
end;
end;
procedure TTestForm.FileListBoxDragOver(Sender: TObject; const Data: TDragObject;
const Point: TPointF; var Accept: Boolean);
begin
Accept := True;
end;
Thank you,
|