Registriert seit: 5. Okt 2007
331 Beiträge
Delphi XE2 Professional
|
Re: TTreeview und Dragdrop
28. Apr 2010, 12:23
Funktioniert.
Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
begin
TreeView1.DragMode := dmAutomatic;
ListBox1.DragMode := dmAutomatic;
ListBox1.Items.Add('A');
ListBox1.Items.Add('B');
ListBox1.Items.Add('C');
TreeView1.Items.Insert(nil, '1');
TreeView1.Items.Insert(nil, 'Telegramme');
TreeView1.Items.Insert(nil, '3');
end;
procedure TForm1.TreeView1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept := Sender = TreeView1;
end;
procedure TForm1.TreeView1DragDrop(Sender, Source: TObject; X, Y: Integer);
var
DropItem, CurrentItem : TTreeNode;
i : Integer;
begin
DropItem := TreeView1.GetNodeAt(X, Y);
if assigned(DropItem) then
begin
if DropItem.Text = 'Telegramme' then
begin
DropItem.DeleteChildren;
TreeView1.Items.AddChild(DropItem, ListBox1.Items.Strings[ListBox1.ItemIndex]);
TreeView1.FullExpand;
end;
end;
end;
|
|
Zitat
|