473,385 Members | 1,326 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,385 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 3861
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, I´m back here to show the new version of the drag & drop table columns (original script ). I´ve found some issues with the old script, specially when trying to use 2 tables with...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.