Autor Beitrag
Daniel_100
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: Sa 01.02.03 21:49 
Hallo!

Ich möchte gerne per Drag&Drop einen Eintrag von einer Listbox in die andere Listbox kopieren.

user defined image

Danke
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Sa 01.02.03 22:08 
Wenn dus umständlich´machen willst gehts so:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
var
  zeilennummer:Integer;

...

procedure TForm1.ListBox1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
zeilennummer:=listbox1.ItemIndex;
end;

procedure TForm1.ListBox1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin

if (x>listbox2.Left-listbox1.Left) and (x<listbox2.Left-listbox1.left+listbox2.Width) then
if (y>listbox2.top-listbox1.Top) and (y<listbox2.top-listbox1.Top+listbox2.height) then
listbox2.Items.Add(listbox1.Items[zeilennummer]) ;
end;


funktionieren tuts aber zumindest ;)

Fiji-Fighter
Daniel_100 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63

Win XP
D3 Prof, D6 Enterprise
BeitragVerfasst: Sa 01.02.03 22:42 
Danke, es funktioniert.

Aber wie kann ich dabei noch den Cursor wechseln?
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Sa 01.02.03 22:52 
beim onmousedown von der listbox :
ausblenden Quelltext
1:
screen.cursor:=crhandpoint;					

bei sämtlichen mouseups dann wieder:
ausblenden Quelltext
1:
screen.cursor:=crdefault;					


Fiji-Fighter
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 01.02.03 23:05 
Wie wäre es hier mit:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
procedure TForm1.ListBox1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
     if Button = mbLeft then Listbox1.BeginDrag(false);
end;

procedure TForm1.ListBox2DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
     if Source is TListbox then Accept := true;
end;

procedure TForm1.ListBox2DragDrop(Sender, Source: TObject; X, Y: Integer);
var
   i : Integer;
begin
  if Source is TListbox And (Listbox1.SelCount > 0) then
  begin
    for i := 0 to Listbox1.Items.Count-1 do
    begin
      if Listbox1.Selected[i] = true then
         Listbox2.Items.Add(Listbox1.Items.Strings[i]);
    end;
  end;
end;
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Sa 01.02.03 23:10 
:schmoll: :schmoll: :schmoll:

ich sag doch meine Lösungen sind (fast) immer umständlich...

aber warum einfach wenns auch komliziert geht???

ich glaube die Quellcodes meiner Programme sind immer 3mal so lang wie die die andere für das gleiche Programm gebraucht hätten :rofl:
Aber vielleicht brauche ich dafür auch nur 1/2 so lang... :lol:


Fiji-Fighter