Изменение позиций элементов ListBox с помощью Drag and Drop 2
Автор: Peter Donnelly
Вот еще одна вариация сабжа.
procedure TPickParty.PickListBMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbLeft then
with Sender as TListBox do
begin
DraggedPM := ItemAtPos(Point(X, Y), True);
if DraggedPM > l;
= 0 then
BeginDrag(False);
end;
end;
procedure TPickParty.PickListBDragOver(Sender, Source: TObject; X,
Y: Integer; State: TDragState; var Accept: Boolean);
begin
if Source = PickListB then
Accept := True;
end;
procedure TPickParty.PickListBDragDrop(Sender, Source: TObject; X, Y: Integer);
var
NewIndex: integer;
begin
NewIndex := PickListB.ItemAtPos(Point(X, Y), False);
if NewIndex > PickListB.Items.Count - 1 then
NewIndex := PickListB.Items.Count - 1;
PickListB.Items.Move(DraggedPM, NewIndex);
PickListB.ItemIndex := NewIndex;
end;
|
|