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
Solved

Drag and Drop

Posted on 2000-04-28
5
259 Views
Last Modified: 2010-05-18
I've got a memo and an Edit control on a form. I want to select a portion of the text and drag it to the edit control so that I will not have to type it in the edit box. This is a good user interface technique, so how will i do it?
0
Comment
Question by:drnadeem
5 Comments
 
LVL 10

Expert Comment

by:ECollin
ID: 2759696
Why don't you just use Copy/Paste on the tmemo and on the TEdit controls.
0
 
LVL 1

Expert Comment

by:l8knight
ID: 2759841
A better way to do it would be to set up a button to copy the selected text into the Edit box, then all you need is

procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit1.Text := Memo1.SelText;
end;

regards

l8knight

p.s. if you really want to drag and drop try the Drag and Drop Component Suite at http://www.melander.dk they are the best I have found.
0
 
LVL 6

Accepted Solution

by:
DrDelphi earned 30 total points
ID: 2759850
Try this out: (dragtext is a global String variable).


procedure TForm1.Memo1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
if Button = mbLeft then  { drag only if left button pressed }
    with Sender as Tmemo do  { treat Sender as TFileListBox }
      begin
        if seltext<>'' then  { is there tezt selected? }
          dragtext:=seltext;
          BeginDrag(False);  { if so, drag it }
    end;

end;

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

procedure TForm1.Edit1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
 edit1.text:=dragtext;
 dragtext:='';
end;
0
 
LVL 17

Expert Comment

by:inthe
ID: 2759927
looks good but how can you first select the text ?
0
 
LVL 1

Author Comment

by:drnadeem
ID: 2761422
instead of Button = mbLeft
use Button = mbRight
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

856 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