Może jednak ktoś coś pomoże z tym przesunięciem wiersza w ListView.
Ja nie mam zielonego pojęcia jak to zrobić.
Już znalazłem :
procedure Exchange(List: TListView; Idx1, Idx2: Integer);
var
Item: TListItem;
begin
Item := TListItem.Create(List.Items);
try
Item.Assign(List.Items[Idx1]);
List.Items[Idx1] := List.Items[Idx2];
List.Items[Idx2] := Item;
finally
Item.Free;
end;
end;
Użycie:
Exchange(ListView, 1, 2);
procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer);
var
APoint: TPoint;
begin
APoint.X := X;
APoint.Y := Y;
index := TListBox(Sender).ItemAtPos(apoint, True);
if Source.ClassType = TListBox then
if TListBox(Source).ItemIndex >= 0 then
begin
TListBox(Sender).Items.Insert(index,TListBox(Source).Items[TListBox(Source).ItemIndex]);
if Sender = Source then TListBox(Source).Items.Delete(TListBox(Source).ItemIndex);
end ;
if Source.ClassType = TCheckBox then
TListBox(Sender).Items.Insert(index,TCheckBox(Source).caption);
end;
procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
accept:=true;
end;