Вниз
Скачать: CL | DM;

drag n drop   Найти похожие ветки 

← →
anod ©   (2002-04-05 14:04) [0]

Пытаюсь в TListBox реализовать Drag"n"Drop, немного не понимаю.
procedure TForm1.DirListDragDrop(Sender, Source: TObject; X, Y: Integer);
var nsource,nsender,i:byte; s,s1:string; doparr:array of string;
begin
nsource:=(Source as TListBox).ItemIndex; //get source index
nsender:=(Sender as TListBox).ItemIndex; //get sender index
s:=d[nsource];
setlength(doparr, length(d));
for i:= 0 to length(d)-1 do doparr[i]:=d[i];
for i:= 0 to length(d)-1 do if i<>nsource then d[i]:=doparr[i];
for i:= nsender to length(d)-1 do
begin
s1:=d[i];
d[i]:=s;
s:=s1;
end;
UpdateDirList; //Отчищяю ListBox и записываю массив D.
end;

Переносит только на 1 позицию. Думаю Source неправильно определяю.


← →
MBo ©   (2002-04-05 14:22) [1]

у тебя nsender и nsource - один и тот же
принимающую позицию определяй по ItemAtPos


← →
anod ©   (2002-04-05 14:23) [2]

Ну, я это понял. А как определить Source.


← →
MBo ©   (2002-04-05 14:24) [3]

sorry, про один и тот же - в случае переноса в одном боксе.


← →
anod ©   (2002-04-05 14:35) [4]

А, если бы у меня было 2 бокса, тогда работал бы Source?


← →
MBo ©   (2002-04-05 14:47) [5]

procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept:=Sender=ListBox1;
end;

procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer);
var pt:TPoint;
s:string;
begin
pt.x:=x; pt.y:=y;
s:=ListBox1.items[ListBox1.ItemIndex];
ListBox1.Items.Delete(ListBox1.ItemIndex);
ListBox1.Items.Insert(ListBox1.ItemAtPos(pt,true),s);
end;



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.46 MB
Время: 0.007 c
7-57901
ATLANTIDO
2002-01-25 13:35
2002.04.18
кЛАВА


1-57713
AlexP
2002-04-08 12:48
2002.04.18
ListBox c табуляцией в строках списка.


1-57782
Migs
2002-04-06 01:59
2002.04.18
Help!!!


1-57678
SPeller
2002-04-04 09:42
2002.04.18
Как сделать, чтобы окно отображалось в таскбаре ??


1-57712
Gari
2002-04-08 11:48
2002.04.18
Прошу помощи!!!




   Наверх