Главная страница
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.006 c
15-1281558594
Юрий
2010-08-12 00:29
2010.11.21
С днем рождения ! 12 августа 2010 четверг


15-1281415535
AlexDn
2010-08-10 08:45
2010.11.21
Ещё один тест музыки


15-1281694348
stas
2010-08-13 14:12
2010.11.21
Regedit открыть на определенной ветке


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


2-1282898767
sergey
2010-08-27 12:46
2010.11.21
Событие TField.OnSetText