Solved

Drag and Drop in a List Box

Posted on 1997-06-04
3
173 Views
Last Modified: 2010-04-06
I am looking for an example how to drag items within a list box
0
Comment
Question by:HarisIV
  • 2
3 Comments
 

Expert Comment

by:richweed
ID: 1336803
Are you working in delphi 2 or 1?

Can you give more details of what you want to do?

Cheers
Richard
0
 

Author Comment

by:HarisIV
ID: 1336804
I am working in Delphi 2 and I want to be able to drag an item for a position in the list and move it in another position in thelist.
0
 

Accepted Solution

by:
richweed earned 60 total points
ID: 1336805
Haris

Here goes, not the most elegant, but it works.

in the OnMouseDown event for the listbox add the following:

lastpos := listbox1.itemindex;

in the OnMouseUp event add:

listbox1.items.move(lastpos,listbox1.itemindex)

Also, add a global variable for the form:

var form1 : TForm;
    lastpos : integer;

This should do it, you can also change the cursor while dragging if you want to (I'll send info if you want to)

Cheers
Richard
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

706 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