[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Drag and drop!!!

Posted on 1999-12-28
3
Medium Priority
?
147 Views
Last Modified: 2010-04-06

how can i drap and drop between Treeview and Listbox

1. from treeview to listbox

many thanx
0
Comment
Question by:karen021897
3 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 2310290
hi,
i have to mention these components(someone else would otherwise for sure  :-):

http://www.melander.dk/delphi/dragdrop/

Regards Barry
0
 
LVL 2

Accepted Solution

by:
hubdog earned 150 total points
ID: 2310998
Here is  a demo . I think perhaps you  should change it to match your demand.
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ComCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    TreeView1: TTreeView;
    procedure TreeView1DragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    procedure ListBox1DragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    procedure ListBox1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure TreeView1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer);
    procedure TreeView1DragDrop(Sender, Source: TObject; X, Y: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.TreeView1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  if (source is TListBox) and (Treeview1.GetNodeAt(x,y)<>nil) then
      accept:=true;
end;

procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  if Source is TTreeView then
    Accept:=true;
end;

procedure TForm1.ListBox1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  aPoint:TPoint;
begin
  APoint.x:=x;
  APoint.Y:=y;
  if listbox1.ItemAtPos(apoint,true)<>-1 then
    listbox1.begindrag(false);
end;

procedure TForm1.TreeView1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  APoint:TPoint;
begin
  APoint.x:=x;
  APoint.y:=y;
  if treeview1.GetNodeAt(x,y)<>nil then
    Treeview1.begindrag(false);
end;

procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer);
var
  aPoint:TPoint;
begin
  aPoint.x:=x;
  aPoint.y:=y;
  if Listbox1.ItemAtPos(APoint,true)=-1 then
    ListBox1.Items.Add(TreeView1.selected.Text)
  else
    listbox1.items.Insert(listbox1.itematpos(aPoint,true),Treeview1.selected.text);
  Treeview1.selected.Delete;
end;

procedure TForm1.TreeView1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
  Treeview1.Items.Insert(TreeView1.selected,Listbox1.Items.strings[Listbox1.itemIndex]);
  Listbox1.Items.Delete(Listbox1.ItemIndex);
end;

end.
0
 

Author Comment

by:karen021897
ID: 2315149
thanks for that,
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
The video provides a quick and easy steps to migrate MBOX file to well known Outlook PST and Office 365. Besides this, it also supports and migrates more than 20 email clients of MBOX which include AppleMail, Opera, Thunderbird and SeaMonkey effortl…
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
Suggested Courses
Course of the Month9 days, 10 hours left to enroll

591 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