Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Drag and Drop Text

Posted on 2013-12-02
4
Medium Priority
?
456 Views
Last Modified: 2013-12-02
hello guys

I have three objects on my form, an Image and two listbox.

There is a listbox with somewords that I'd like to drag it to my empty listbox and insert the text there, but I'd like to know how can I drag and drop the text on the image and it send the text to the listbox above it.

I am sending an example made in D7, please give me an example how to do that, drag and drop text from listbox to another and listbox to image that will send automaticly to the above listbox.

Thanks
Alex
DropImage.zip
0
Comment
Question by:hidrau
[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
  • 2
  • 2
4 Comments
 
LVL 19

Expert Comment

by:Thommy
ID: 39689540
I think that's it, what you are looking for...
How to Move ListBox Items with the Mouse (Drag and Drop)
0
 
LVL 1

Author Comment

by:hidrau
ID: 39689553
Hello Thommy,

From a listbox to another listbox I know how, but if I drag the text into the image, how can I send it automatically to my empty listbox? That is the problem.
0
 
LVL 19

Accepted Solution

by:
Thommy earned 2000 total points
ID: 39689906
Below code adds Listbox2 drag item to Listbox1, when dropped on Image1...

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, jpeg, ExtCtrls;

type
  TForm1 = class(TForm)
    Image1: TImage;
    ListBox1: TListBox;
    ListBox2: TListBox;
    Label1: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Image1DragDrop(Sender, Source: TObject; X, Y: Integer);
    procedure Image1DragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  ListBox2.DragMode := dmAutomatic;
end;

procedure TForm1.Image1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
  ListBox1.Items.Add( (Source as TListBox).Items[(Source as TListBox).ItemIndex] );
end;

procedure TForm1.Image1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  Accept := Source = ListBox2;
end;

end.

Open in new window

DropImageNew.zip
0
 
LVL 1

Author Closing Comment

by:hidrau
ID: 39691343
Thanks very much for the help
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

721 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