Карта сайта Kansoftware
НОВОСТИУСЛУГИРЕШЕНИЯКОНТАКТЫ
Разработка программного обеспечения
KANSoftWare

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

Delphi , Синтаксис , Drag and Drop

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

Code:
{
This example shows how to drag&drop within a TListBox.
The Demo Program also shows how to implement an autoscroll-feature.
}
 
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;
Взято с сайта: http://www.swissdelphicenter.ch

Статья Drag and Drop со списками раздела Синтаксис Drag and Drop может быть полезна для разработчиков на Delphi и FreePascal.


Комментарии и вопросы


Ваше мнение или вопрос к статье в виде простого текста (Tag <a href=... Disabled). Все комментарии модерируются, модератор оставляет за собой право удалить непонравившейся ему комментарий.

заголовок

e-mail

Ваше имя

Сообщение

Введите код




Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.



:: Главная :: Drag and Drop ::


реклама



©KANSoftWare (разработка программного обеспечения, создание программ, создание интерактивных сайтов), 2007
Top.Mail.Ru Rambler's Top100
19.04.2024 14:02:09/0.036346197128296/2