Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2010.11.21;
Скачать: CL | DM;

Вниз

В TListBox с помощью мыши поменять Items   Найти похожие ветки 

 
Andrey K   (2010-09-01 22:58) [0]

Доброго времени суток. Подскажите, как в TListBox с помощью мыши поменять Items, т. е. одну позицию перетащить в другую (была десятая, стала вторая). Или другой компонент более подходящих для этой операции.


 
dzmitry_loktseu   (2010-09-01 23:33) [1]

если не заморачиваться, то можно так:


private
  Fidx: Integer;



procedure TForm1.ListBox1MouseDown(Sender: TObject; Button: TMouseButton;
 Shift: TShiftState; X, Y: Integer);
begin
 if Button = mbLeft then
   with TListBox(Sender) do
     FIdx := ItemIndex;
end;

procedure TForm1.ListBox1MouseUp(Sender: TObject; Button: TMouseButton;
 Shift: TShiftState; X, Y: Integer);
begin
   if Button = mbLeft then
     with TListBox(Sender) do
       Items.Move(Fidx, ItemIndex);
end;


 
sniknik ©   (2010-09-01 23:53) [2]

да и так вроде заморочек не особо...

procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
var
 i, n: integer;
begin
 with TListBox(Sender) do begin
   i:= ItemAtPos(Point(X, Y), true);
   n:= ItemIndex;
 end;
 Accept:= (Sender = Source) and (i >= 0) and (n >= 0) and (i<>n);
end;

procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
 with ListBox1 do
   Items.Move(ItemIndex, ItemAtPos(Point(X, Y), true));
end;


ну еще в дизайне драгмоде в "автомат" поставить.


 
Andrey K   (2010-09-02 00:07) [3]

Спасибо за подсказку ):



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

Текущий архив: 2010.11.21;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.01 c
15-1281097289
Человек
2010-08-06 16:21
2010.11.21
Зачем по всему городу кладут желтые плиты на тротуарах?


15-1281472194
Юрий
2010-08-11 00:29
2010.11.21
С днем рождения ! 11 августа 2010 среда


3-1247648524
Цукор5
2009-07-15 13:02
2010.11.21
ожидание запуска FireBird a


2-1283367516
Andrey K
2010-09-01 22:58
2010.11.21
В TListBox с помощью мыши поменять Items


15-1282002935
Дмитрий С
2010-08-17 03:55
2010.11.21
Синхронизация доступа к хешу.