Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

DragDrop in Listbox

Posted on 1997-11-21
3
Medium Priority
?
313 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 200 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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 tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

604 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