Frequently Asked Component Specific Questions
Options |
Display all FAQ items |
Displaying items 1 to 1 of 1, page 1 of 1
<< previous next >>
TMS Advanced Poly List
Drag and Drop over TCustomItem
Drag and Drop over TCustomItem
Drag & Drop needs to be implemented manually, below is code that inserts or adds an item based on TCustomItem. The item also be a custom class that inherits from TCustomItem. The code below is drag & drop code based on 2 TAdvPolyList instances, where the item to be dropped is obtained from the DropItem function. But the Source can come from another component as well.
procedure TForm1.AdvPolyList1DragDrop(Sender, Source: TObject; X, Y: Integer); var it, itdrop: TCustomItem; begin it := (Source as TAdvPolyList).DropItem; itdrop := AdvPolyList1.List.ItemAtXY(X, Y); if Assigned(itdrop) then AdvPolyList1.InsertItem(itdrop.Index, TCustomItemClass(it.ClassType)).Assign(it) else AdvPolyList1.AddItem(TCustomItemClass(it.ClassType)).Assign(it); end; procedure TForm1.AdvPolyList1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin Accept := Source is TAdvPolyList; end;