473,224 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

Drag & Drop

Hi,

I"m trying to use drag & drop of text from one text box to
another but without suceess.
Microsoft presented an example in "101 code samples" BUT
in this example the code select and drag all the text in
the TextBox, wether the user wants or not.
I need to drag only the selected text (changing the
example causes it not to work).

Thanks in advance
Nov 20 '05 #1
3 3851
I don't think what you're trying to do is a good idea.
DragDrop is really a concept for objects.
For text Cut/Copy/Paste is the default solution.

Suppose you did succeed in implementing Drag and Drop for the selected
text. Think about the user experience.
They want to try and select a different range of text and instead when they
hold the mouse down your dragdrop begins. This would be quite frustrating
for customers.

Cameron McColl
Microsoft
--------------------
| Content-Class: urn:content-classes:message
| From: "Goldwind" <go******@netvision.net.il>
| Sender: "Goldwind" <go******@netvision.net.il>
| Subject: Drag & Drop
| Date: Sun, 31 Aug 2003 01:52:37 -0700
| Lines: 11
| Message-ID: <04****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcNvnTqRPAdJPoPZQMqN4Wf2Y7GmQA==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.languages.vb
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:132773
| NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| Hi,
|
| I"m trying to use drag & drop of text from one text box to
| another but without suceess.
| Microsoft presented an example in "101 code samples" BUT
| in this example the code select and drag all the text in
| the TextBox, wether the user wants or not.
| I need to drag only the selected text (changing the
| example causes it not to work).
|
| Thanks in advance
|

Nov 20 '05 #2
Cameron,

I think the Drag & Drop, in this case, may simplify the work of a user.
What is prefered?
1) select text -> do copy -> go to the other field -> do paste
OR
2) select text -> drag to the other field

When you drag an image control which present an image object, you dont
mean to accept the all control. you want in only to transfer the image.
same with listbox and treeview etc. in these two cases, you are not
interested in draging a line, you are interested in transferring their
text.
(We did got a positive feedbacks from users)

Is There a technical solution to this problem, in the current version of
.Net 2003?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3
Fair enough, rather than debate the design pros and cons I think this code
is what you're looking for.
Note: This will only work for RichTextBox controls and not standard
textboxes. The reason being that a standard textbox loses it's selectedtext
BEFORE the mousedown event gets processed.
Private Sub RichTextBox1_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragDrop
RichTextBox1.Text =
RichTextBox1.Text.Insert(RichTextBox1.SelectionSta rt,
e.Data.GetData(System.Windows.Forms.DataFormats.Te xt, True))
End Sub
Private Sub RichTextBox2_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles RichTextBox2.MouseDown
If RichTextBox2.SelectedText.Length > 0 Then
Dim s As String = RichTextBox2.SelectedText
RichTextBox2.DoDragDrop(s, DragDropEffects.Copy)
End If
End Sub

Private Sub RichTextBox1_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles RichTextBox1.DragEnter
If e.Data.GetDataPresent(DataFormats.Text) Then
e.Effect = DragDropEffects.Copy
End If
End Sub

Cameron McColl
Microsoft
--------------------
| From: Goldwind @ <go******@netvisiob.net.il>
| References: <04****************************@phx.gbl>
| X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
| Subject: Re: Drag & Drop
| Mime-Version: 1.0
| Content-Type: text/plain; charset="us-ascii"
| Content-Transfer-Encoding: 7bit
| Message-ID: <#C**************@TK2MSFTNGP11.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.vb
| Date: Wed, 03 Sep 2003 00:56:51 -0700
| NNTP-Posting-Host: actionjackson133.dsl.frii.net 216.17.147.133
| Lines: 1
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:133713
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| Cameron,
|
| I think the Drag & Drop, in this case, may simplify the work of a user.
| What is prefered?
| 1) select text -> do copy -> go to the other field -> do paste
| OR
| 2) select text -> drag to the other field
|
| When you drag an image control which present an image object, you dont
| mean to accept the all control. you want in only to transfer the image.
| same with listbox and treeview etc. in these two cases, you are not
| interested in draging a line, you are interested in transferring their
| text.
| (We did got a positive feedbacks from users)
|
| Is There a technical solution to this problem, in the current version of
| .Net 2003?
|
| *** Sent via Developersdex http://www.developersdex.com ***
| Don't just participate in USENET...get rewarded for it!
|

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Karsten Schramm | last post by:
Hi, if I drag an Outlook.MailItem to a Windows-Explorer window a <subject>.msg file will be created. Now I try to drag & drop a mail item to my own WinForm app. Unfortunately it doesn't work....
0
by: Plumer | last post by:
Hello everyone, Yesterday I posted a message about implementing drag & drop in a TreeView control. I'm having real difficulty getting this to work -- the process seems to be incredibly...
2
by: Grey | last post by:
I need to design a workflow application with C#. I want to design an UI with some workflow components which they can be drag & drop anywhere in order to design the workflow for the application...
2
by: Ivo Tcholakov | last post by:
Is it possible to drag and drop controls in an aspx page at runtime ? Meaning i have developed a ASP.NET web form, the web form is now downloaded in IE - now can i have this form to detect mouse...
6
by: jojobar | last post by:
Hello, I look at the asp.net 2.0 web parts tutorial on the asp.net web site. I tried to run it under firefox browser but it did not run. If I want to use this feature in a commercial product...
1
by: Terry Olsen | last post by:
My first time using TreeViews. I have TreeView1 set up to display my directory structure just like Windows Explorer. I can drag & drop files and folders over to TreeView2. I can re-arrange the...
3
by: VB Programmer | last post by:
In VB.NET 2005 (winform) any sample code to drag & drop items between 2 listboxes? Thanks!
5
by: sesar | last post by:
How can I impement drag&drop for simple 'dialog base' application... I want to drag&drop txt file and load the text to variable
5
by: Romulo NF | last post by:
Greetings, Im back here to show the new version of the drag & drop table columns (original script ). Ive found some issues with the old script, specially when trying to use 2 tables with...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.