Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 182
  • Last Modified:

Drag and Drop in a List Box

I am looking for an example how to drag items within a list box
0
HarisIV
Asked:
HarisIV
  • 2
1 Solution
 
richweedCommented:
Are you working in delphi 2 or 1?

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

Cheers
Richard
0
 
HarisIVAuthor Commented:
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
 
richweedCommented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now