Solved

Drag and Drop in a List Box

Posted on 1997-06-04
3
174 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
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, f…

920 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

16 Experts available now in Live!

Get 1:1 Help Now