Solved

Drag and Drop

Posted on 2000-04-28
5
261 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
[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
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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 is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

696 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