Solved

DragDrop in Listbox

Posted on 1997-11-21
3
304 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now