Вниз
Скачать: 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.008 c
3-57638
Alxn
2002-03-28 14:22
2002.04.18
Имя текущего поля


6-57831
Василий Свиридов
2002-01-31 05:28
2002.04.18
Подскажите пожалуйста...


3-57615
sysoper
2002-03-28 07:10
2002.04.18
Ошибка в IB5.6 +Win2000 server+sp2


7-57908
harisma
2001-10-31 16:02
2002.04.18
ИК порт и работа с ним


1-57743
ymin
2002-04-05 12:17
2002.04.18
Для чего нужно использовать MDI и API (в двух словах...)




   Наверх