Недавно добавленные исходники

•  DeLiKaTeS Tetris (Тетрис)  3 771

•  TDictionary Custom Sort  5 886

•  Fast Watermark Sources  5 682

•  3D Designer  8 442

•  Sik Screen Capture  6 020

•  Patch Maker  6 466

•  Айболит (remote control)  6 461

•  ListBox Drag & Drop  5 318

•  Доска для игры Реверси  94 875

•  Графические эффекты  6 665

•  Рисование по маске  5 772

•  Перетаскивание изображений  4 841

•  Canvas Drawing  5 218

•  Рисование Луны  4 944

•  Поворот изображения  4 484

•  Рисование стержней  3 179

•  Paint on Shape  2 424

•  Генератор кроссвордов  3 298

•  Головоломка Paletto  2 607

•  Теорема Монжа об окружностях  3 390

•  Пазл Numbrix  2 245

•  Заборы и коммивояжеры  2 901

•  Игра HIP  1 871

•  Игра Go (Го)  1 785

•  Симулятор лифта  2 121

•  Программа укладки плитки  1 852

•  Генератор лабиринта  2 289

•  Проверка числового ввода  1 978

•  HEX View  2 287

•  Физический маятник  1 953

 
скрыть

  Форум  

Delphi FAQ - Часто задаваемые вопросы

| Базы данных | Графика и Игры | Интернет и Сети | Компоненты и Классы | Мультимедиа |
| ОС и Железо | Программа и Интерфейс | Рабочий стол | Синтаксис | Технологии | Файловая система |



Delphi Sources

Drag and Drop со списками



Оформил: DeeCo

{ 
 This example shows how to drag&drop within a TListBox. 
 The Demo Program also shows how to implement an autoscroll-feature. 

 Dieses Beispiel zeigt, wie man drag & drop in einer TListBox realisiert. 
 Im Demo-Programm wird auch eine Autoscroll-Funktion gezeigt. 
}

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

 procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer);
 var
   iTemp: Integer;
   ptTemp: TPoint;
   szTemp: string;
 begin
   { change the x,y coordinates into a TPoint record }
   ptTemp.x := x;
   ptTemp.y := y;

   { Use a while loop instead of a for loop due to items possible being removed 
   from listboxes this prevents an out of bounds exception }
   iTemp := 0;
    while iTemp <= TListBox(Source).Items.Count-1 do
   begin
     { look for the selected items as these are the ones we wish to move }
     if TListBox(Source).selected[iTemp] then
     begin
       { use a with as to make code easier to read }
       with Sender as TListBox do
       begin
       { need to use a temporary variable as when the item is deleted the 
        indexing will change }
         szTemp := TListBox(Source).Items[iTemp];

         { delete the item that is being dragged  }
         TListBox(Source).Items.Delete(iTemp);

       { insert the item into the correct position in the listbox that it 
       was dropped on }
         Items.Insert(itemAtPos(ptTemp, True), szTemp);
       end;
     end;
     Inc(iTemp);
   end;
 end;




Похожие по теме исходники

Текст Drag & Drop

Drag and Drop Text

Quick Drag & Drop

Dragster Tree Relay

 

ListBox Drag & Drop

Backup and Restore

Market Monitoring and Billing

Black and White Effects

 

Sand Dog

Wave and MIDI In-Out

Vista and 7 Sound

Improved Buttons and ProgressBar

 

Desktop Sands

Rotation and Symmetry

Dropper (пипетка Фотошоп)




Copyright © 2004-2025 "Delphi Sources" by BrokenByte Software. Delphi World FAQ

Группа ВКонтакте