Solved

DragDrop in Listbox

Posted on 1997-11-21
3
308 Views
Last Modified: 2010-04-04
Can somebody give me an example of how I should a dragdrop action in a TListBox? (The user can select an item and drag it to another item to change the sequence of the items)
(I've done it alteady,but I'm afraid my coding is a bit sloppy )
Thanks again!
PS I'm now working on my first Delphi Project,and I love it! But there's a lot of 'simple' things I just can't figure out  from the books or Delphi Help,so I very glad with all your help.
0
Comment
Question by:lizzzard
3 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1351398
Hi lizzzard,

Dragging and dropping in the same listbox or from one to another listbox?


0
 

Author Comment

by:lizzzard
ID: 1351399
Hi ZifNab,
In the same listbox.
0
 
LVL 1

Accepted Solution

by:
TheSwine earned 50 total points
ID: 1351400
Here is a working source:

procedure TEnColumnsEditor.ColsListMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  MoveFrom := ColsList.ItemAtPos(Point(X,Y),True);
  if MoveFrom <> -1 then ColsList.BeginDrag(False);
end;

procedure TEnColumnsEditor.ColsListDragOver(Sender, Source: TObject; X,
  Y: Integer; State: TDragState; var Accept: Boolean);
begin
  Accept := (ColsList.ItemAtPos(Point(X,Y),True) <> - 1) and
    (ColsList.ItemAtPos(Point(X,Y),True) <> MoveFrom);
end;

procedure TEnColumnsEditor.ColsListDragDrop(Sender, Source: TObject; X,
  Y: Integer);
begin
  ColsList.EndDrag(True);
    NewColumns.Exchange(MoveFrom, ColsList.ItemAtPos(Point(X,Y),True));
  RefreshList;
end;

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help on project with Soap 10 57
Downloading email attachments 2 79
When i run adoquery my application freezes 26 178
Twebbrowser add css to the header 3 27
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question