Вниз
Скачать: 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.45 MB
Время: 0.008 c
1-57762
andreik
2002-04-05 15:43
2002.04.18
Ширина делений в ProgressBar


1-57667
vlv
2002-04-04 21:32
2002.04.18
Проблема с MDIForm


6-57838
Vks
2002-02-05 15:36
2002.04.18
Как можно измерить трафик, программы (в моем случае сетевая БД)?


1-57715
Tiomik
2002-04-08 12:39
2002.04.18
какие книги посоветуете начинающему програмисту???


1-57702
ymin
2002-04-08 10:12
2002.04.18
а как форму с stringGrid или stringGrid из формы сохранить в форм




   Наверх