hallo,
ich habe eine Anwendung mit mehrere Listboxen. Meine ziel ist es, sowohl die reihenfolge innerhalb ein Listbox ändern als auch objekte in andere Listbox ziehen. Reihenfolge Änderung Innerhalb ein listbox funktioniert aber Objekt in anderem Listboxen ziehen funktioniert nicht. hier ist meine quelle:
Delphi-Quellcode:
var
Form3: TForm3;
// form level
StartingPoint : TPoint;
implementation
{$R *.dfm}
...............................
procedure TForm3.FormCreate(Sender: TObject);
begin
ListBox_strengths.Items.Add('ich');
ListBox_strengths.Items.Add('du');
ListBox_strengths.DragMode := dmAutomatic;
ListBox_themen.DragMode:= dmAutomatic;
ListBox_themen.Items.Add('mo');
ListBox_themen.Items.Add('no');
Listbox_themen.MultiSelect:=true;
end;
procedure TForm3.ListBox_themenDragDrop(Sender, Source: TObject; X,
Y: Integer);
var
DropPosition, StartPosition, I: Integer;
DropPoint: TPoint;
a: string;
begin
DropPoint.X := X;
DropPoint.Y := Y;
with Source as TListBox do
begin
StartPosition := ItemAtPos (StartingPoint,True) ;
DropPosition := ItemAtPos(DropPoint,True) ;
Items.Move(StartPosition, DropPosition) ;
end;
if Source is TListBox then
begin
for i := 0 to TListBox(Source).Items.Count-1 do
if TListBox(Source).Selected[i] then
a:= ListBox_themen.Items.Strings[i];
ListBox_strengths.Items.Add(a);
end;
end;
procedure TForm3.ListBox_themenDragOver(Sender, Source: TObject; X,
Y: Integer; State: TDragState; var Accept: Boolean);
begin
Accept := Source = ListBox_themen;
if Source is TListBox then
begin
accept:= true;
end;
end;
......................................................................
procedure TForm3.ListBox_strengthsDragDrop(Sender, Source: TObject; X,
Y: Integer);
var
DropPosition, StartPosition, I: Integer;
DropPoint: TPoint;
begin
DropPoint.X := X;
DropPoint.Y := Y;
with Source as TListBox do
begin
StartPosition := ItemAtPos (StartingPoint,True) ;
DropPosition := ItemAtPos(DropPoint,True) ;
Items.Move(StartPosition, DropPosition) ;
end;
if Source is TListBox then begin
for i := 0 to TListBox(Source).Items.Count-1 do
if TListBox(Source).Selected[i] then
ListBox_strengths.Items.Add(TListBox(Source).Items[i]);
end;
end;
procedure TForm3.ListBox_strengthsDragOver(Sender, Source: TObject; X,
Y: Integer; State: TDragState; var Accept: Boolean);
begin
Accept := Source = ListBox_strengths;
if Source is TListBox then
begin
accept:= true;
end;
end;
onMouseDown von beide stehen: StartingPoint.X := X; StartingPoint.Y := Y;
weisst jemand, wo das Problem liegen kann?
grüß
poter