Drag & Drop text

Hello,

Implementing drag & drop in C# seems pretty easy.  However, in attempting to 
do so I ran into an issue that I don't understand.  I found that I could drag 
& drop icons but when I tried to drag & drop text it would always display the 
red circle with the bar through it, so I would never even get to the point of 
being allowed to drop it.  As first I thought it was something wrong in my 
code (which it may still be), but when I tried to drag & drop text between 
two 3rd party text editor applications like Wordpad and UltraEdit, it 
wouldn't let me do that either.  However, I could drag text from one point to 
another within the same application.  Do you have any idea why dragging & 
dropping text between different applications wouldn't work?

Thanks,
Ray

0
Utf
5/28/2010 8:46:09 AM
dotnet.languages.csharp 1931 articles. 0 followers. Follow

3 Replies
740 Views

Similar Articles

[PageSpeed] 36

Ray Mitchell wrote:
> Hello,
> 
> Implementing drag & drop in C# seems pretty easy.  However, in attempting to 
> do so I ran into an issue that I don't understand.  I found that I could drag 
> & drop icons but when I tried to drag & drop text it would always display the 
> red circle with the bar through it, so I would never even get to the point of 
> being allowed to drop it.  As first I thought it was something wrong in my 
> code (which it may still be), but when I tried to drag & drop text between 
> two 3rd party text editor applications like Wordpad and UltraEdit, it 
> wouldn't let me do that either.  However, I could drag text from one point to 
> another within the same application.  Do you have any idea why dragging & 
> dropping text between different applications wouldn't work?

If you've looked into how drag & drop is implemented in your 
application, then you know that your application has to handle certain 
events, and in doing so has to inspect the data types available on the 
clipboard and decide whether it can handle those data types or not.

I can't explain the specific behavior between Wordpad and UltraEdit, but 
presumably neither is publishing on the clipboard a data format the 
other recognizes.  Likewise, if you want to be able to drag & drop text 
into your application, you need to make sure that a) the application 
sending the text is really putting a text format on the clipboard, and 
b) your application is really reporting that it can handle the text 
format on the clipboard, and of course c) that it actually _can_ handle 
the text format on the clipboard.

There are multiple types of text formats (e.g. plain text and RTF), so 
make sure your application is able to handle the ones you care about.

Without a concise-but-complete code example that reliably demonstrates 
the problem, it would not be possible to provide advice much more 
specific than the above with respect to what is actually wrong with your 
program.

Pete
0
Peter
5/28/2010 9:32:16 AM

"Peter Duniho" wrote:

> Ray Mitchell wrote:
> > Hello,
> > 
> > Implementing drag & drop in C# seems pretty easy.  However, in attempting to 
> > do so I ran into an issue that I don't understand.  I found that I could drag 
> > & drop icons but when I tried to drag & drop text it would always display the 
> > red circle with the bar through it, so I would never even get to the point of 
> > being allowed to drop it.  As first I thought it was something wrong in my 
> > code (which it may still be), but when I tried to drag & drop text between 
> > two 3rd party text editor applications like Wordpad and UltraEdit, it 
> > wouldn't let me do that either.  However, I could drag text from one point to 
> > another within the same application.  Do you have any idea why dragging & 
> > dropping text between different applications wouldn't work?
> 
> If you've looked into how drag & drop is implemented in your 
> application, then you know that your application has to handle certain 
> events, and in doing so has to inspect the data types available on the 
> clipboard and decide whether it can handle those data types or not.
> 
> I can't explain the specific behavior between Wordpad and UltraEdit, but 
> presumably neither is publishing on the clipboard a data format the 
> other recognizes.  Likewise, if you want to be able to drag & drop text 
> into your application, you need to make sure that a) the application 
> sending the text is really putting a text format on the clipboard, and 
> b) your application is really reporting that it can handle the text 
> format on the clipboard, and of course c) that it actually _can_ handle 
> the text format on the clipboard.
> 
> There are multiple types of text formats (e.g. plain text and RTF), so 
> make sure your application is able to handle the ones you care about.
> 
> Without a concise-but-complete code example that reliably demonstrates 
> the problem, it would not be possible to provide advice much more 
> specific than the above with respect to what is actually wrong with your 
> program.
> 
> Pete
> .
> 
Hi Pete,

Yes, I have implemented the proper events in my code and I am considering 
the various types of things that may be dragged and dropped.  However, you 
mention something that is probably at the root of the problem.  Obviously I 
don't know much about the underlying mechanisms that make drag and drop work 
so I just assumed that if drag and drop worked withing a particular 
application it should also work between such applications, such as between 
UltraEdit and Wordpad.  But you mentioned that an application might not 
actually use the clipboard to perform drag and drop of text, so that is 
probably the reason for the behavior I am seeing.  So, how would such 
applications be doing drag and drop of text if they don't do it that way?  Is 
there some reason that they would want to do it that way instead?

Thanks,
Ray
0
Utf
5/28/2010 4:49:01 PM
Ray Mitchell wrote:
> [...] But you mentioned that an application might not
> actually use the clipboard to perform drag and drop of text, so that is 
> probably the reason for the behavior I am seeing.  So, how would such 
> applications be doing drag and drop of text if they don't do it that way?  Is 
> there some reason that they would want to do it that way instead?

An application may bypass the clipboard when doing D&D internally simply 
because it's more efficient.  Even if it does use the clipboard, it may 
put some proprietary format onto the clipboard rather than one that is 
portable to other applications.


Basically, you need to write your drag/drop target code so that you 
accept as many different pre-defined formats as possible (see the 
clipboard API for specific formats), and then hope that the other 
application will in fact be publishing one of those formats on the 
clipboard when it acts as a drag/drop source.

Pete
0
Peter
5/29/2010 2:53:06 AM
Reply:

Similar Artilces:

Split body text between two slides in PowerPoint 2007
I would like to split body text between two slides the way the instructions say I should be able to do. That is, I would like to be working in the Outline tab, position the Insert point, and press the Enter key. This does not work for me. Instead of splitting the slide into two, I just get a new blank slide after the slide I'm trying to split. Does anyone know what I'm doing wrong, or are the instructions just wrong? I think the instructions are incomplete. Hitting Enter creates the title placeholder of the next slide for you. Hit Enter again and then Tab to continue...

Drop Down list with colours
Hi, Is there any way in Excel to create a drop down list which contains colours? For example to show RAG status (i.e. Red Amber Green). At the moment I can only show text in the drop down list. Would anyone know a way of working around this? Thanks. Thanks Roger, and Chip, for replying. I was playing around with it and found that I could conditionally format the cell depending on the text selected - so if I choose "RED" it goes red. It's just about enough to work for what I intend to use it for, but I'll experiment with your suggestion in case I need to develop thi...

Help Text for Radio Buttons
I am trying to create a survey form with multiple choice radio buttons. I want to add descriptive text that appears when you float your cursor over the button (like that for a toolbar icon). I've scoured Excel help and couldn't find anything. I don't have experience with macros or Visual Basic but am willing to try if someone can hold my hand through it. If the radio button is in a cell, add a comment to the cell. Then the instructions will appear when the mouse hovers over the cell. -- Damon Longworth Don't miss out on the 2005 Excel User Conference Sept 16th and 17th...

Drag and drop with CRichEditCtrl
I have an application that makes heavy use of the rich edit control. One of the things I needed to do was to customize text when it is pasted or dropped onto the rich edit control. This wasn't too hard to do: I have an object implementing IRichEditOleCallback attached to the rich edit, and in the QueryAcceptData() method I modify the data as needed before adding it to the control. My problem comes with drag and drop, specifically with the "move" drop operation. Following the MSDN documentation, my QueryAcceptData() method returns S_FALSE to indicate that it's processed the d...

Using Texts in Cells
I have a list of parts numbers (alphabetical and numeric) and want to use these in a sum. How can I include these in a sum eg if C1= EV1, C2=EV2? Alternatively if not possible can I use the SUBSTITUTE function to pick this text from a list Thanks in advance do you wnat to do a sum or a count? if a count, check the countif() function in help "Duncan" wrote: > I have a list of parts numbers (alphabetical and numeric) and want to use > these in a sum. > How can I include these in a sum eg if C1= EV1, C2=EV2? > Alternatively if not possible can I use the SUBSTITUTE func...

Drag n' Drop emails to a Java application
Hi, We are developing a Java application where we want to import information received in e-mails. The email client are Outlook 2003 (at least for now). The best way would be to be able to drag the e-mail to the Java app and then access/parse the e-mail in the Java app. I have searched the web but can not find anything useful. Do I have to use COM and/or OLE for doing such operations? Please help me!! Best Regards Joacim ...

Drop Downs and lookups from other sheets
I have a workbook where the front sheet is a display page and the three sheets behind are reserved for data tables. What I want to do is have one cell in the front page which is a drop down and selects names from one of the tables on the other sheets. From there I can use Vlookup to populate the info from the tables on the front page based on that name. The problem is I can't seem to get this list of names from another sheet. Every time I try, I get an error. How would I do this? thanks! Hi,. first insert a name for your list in the other sheet, go to insert, name, ...

Drop-down data not appearing in exported XML
I'm exporting data as XML from an Excel spreadsheet. Cells with plain text in them work fine, but cells with a selection from a drop-down list do not. The XML file shows everything is there, except data from cells with drop-down selections. No error message generated, just no trace of the data. Any suggestions? thanks kc Fixed the problem. Found out that the drop-downs were actually objects placed on top of the cell, the options were not coded into the cells themselves. "Kristi" <kristi@NOSPAMinscriber.com> wrote in message news:MaCdnWD2xtF6CtveRVn-qQ@golden.net... > ...

Drop down list #8
I created a drop down list using the data, validation menu. It works well. However, I only have two items in the list and I am wondering if there is a better way to alternate between them. With the drop down list it takes a couple of clicks. First you select the cell, then you click to drop down the list, then you highlight the item, then you click on it. Is there a way to select the alternate item with fewer clicks? Don, You need only click the cell, click the dropdown button, then click the desired item. Three clicks. This event-fired sub will alternate between "Choice a&qu...

Formfield Default Text Question
Hi all, I'm programatically adding some formfields, one of which I want to have some default text displayed , altho I'm having no problem creating the formfields and setting it's default text, i cannot figure out how to update the formfield to show this default text without resetting the contents of all formfields. A snippet from the code is: Selection.FormFields.Add Range:=Selection.Range, Type:=wdFieldFormTextInput oTableTarget.Rows.Last.Cells(j).Select With Selection.FormFields(1) .EntryMacro = "DeleteRow" With ....

MS CRM Full Text Index for Attachements
As many have experienced, finding something after you've put it into MS CRM can be difficult. In an attempt to solve this problem specifically for file attachments (to emails, notes, etc.), I'm toying with the idea of adding full text indexes to the AnnotationBase table. And then creating an SDK front end to do the searching. Has anyone configured MS CRM in this way? Is there a better way to accomplish searching documents that are attached and in the database? Thanks, Dean Dean, I'm not sure this will work. The attachments are stored as BLOBs in the database so I don'...

My Drag Image Flickers
Hi guys, My drag image flickers, I understand the cause of this (I think) but I don't know how to fix it. I use this to auto-scroll during a drag and drop: // in OnTimer() m_pDragImage->DragShowNolock(FALSE); SendMessage(WM_VSCROLL,MAKEWPARAM(SB_LINEDOWN,0),NULL); m_pDragImage->DragShowNolock(TRUE); So since I'm hiding it, then showing it again, it flickers. Can I fix this ? Thanks, Robert A. ...

dragging array UDFs
Hi I built an array function and it is working well. However when I dra it to other cel regions I got the message "VALUE". The exact formul and the code is below. Thanks for any help. Eduardo Exact formula: {=samLMR(B5:B20;0;0)} Code: x is a sorted array. Public Function samLMR(x As Variant, Optional a As Double = 0# Optional b As Double = 0#) As Variant Dim xmom() As Double Dim xm() As Double Dim sum(8) As Double Dim R As Integer Dim C As Integer Dim ReturnColumn As Boolean R = Selection.Rows.Count C = Selection.Columns.Count n = x.Count n = n - nfails If R < C Then nm...

Drag and Drop Emails
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Email Client: Exchange Within entourage, when I drag and drop an email from my inbox to another folder, it &quot;copy/pastes&quot; it instead of moving it permanently so it stays in the original location where I was trying to move it from. Seems the only way around this is to right click on the email and select &quot;Move to&quot; and then select a folder (but I have dozens of folders and this is not quick at all). <br><br>Is there a way to change my settings so when I drag and drop emails, it's a &am...

how do I set up a header or a footer in the dropping down menu to.
I am trying to set up a footer that I can use throughout many workbooks, just not the sheets. Is there a way do this by setting it up as a predetermined footer or header in the drop down menu You can use a template for new workbooks and new sheets that includes the headers and footers you want. See Help for more information. But this will affect only new workbooks and worksheets, not existing ones. For them, you'll have to change each one manually. On Tue, 19 Oct 2004 12:03:05 -0700, Chrisanna <Chrisanna@discussions.microsoft.com> wrote: >I am trying to set up a footer that ...

Trying to drop MSCRMDistribution table
I'm trying to delete the CRM tables from SQL, but keep getting "Error 3724: Cannot drop the database because it is being used for replication.". I ran sp_removedbreplication against all of them, and I was able to delete the first three, but the MSCRMDistribution table is still there. The database icon in Enterprise Manager does not have a hand underneath, so I'm not sure why I'm getting this error. How can I drop this table? In case anyone is wondering why I'm doing this, I attempted to install CRM earlier this week, but things went astray with the IIS setti...

Graph with text
I have a status field "Open, Working, On-Hold, or Done" and a second column for project name. I want to create a chart that shows the project name on the x-axis and the status on the Y axis. THIS IS A SECOND REQUEST, please help. DDBeards You need to convert the status to a numerical scale (1,2,3,4), plot X=project vs Y=numerical status, and finally fix up the vertical axis: http://peltiertech.com/Excel/Charts/Y_CategoryAxis.html - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical Services Tutorials and Custom Solutions http://PeltierTech.com/ _______ DDBe...

Drag Capabilities #2
Guys, I seem to have lost that little plus sign that appears in the right hand bottom corner of the cell that allows for dragging formatting and content onto other cells. Help in the this would be greatly appreciated. Regards, Subodh Help is available in Excel Help. Try the term "fill handle". -- David Biddulph <subodh.mallya@gmail.com> wrote in message news:02f26450-f3a3-4b84-a5f2-a80c1513dd14@v39g2000pro.googlegroups.com... > Guys, > > I seem to have lost that little plus sign that appears in the right > hand bottom corner of the cell that allows for draggin...

drag and drop
I am running Word 07 with Vista. I've lost my "drag and drop" function for moving text in my recent documents. I can select text, but when I click a second time to get the "dragging" arrow, nothing happens and I can't move the text. The option to enable this function under "Advanced" IS checked. I can still cut and paste. I am a freelance editor and have recently installed some templates with macros and add-ins, and I have attached one of them to my normal.dotx for regular use. However, I can't 100% for sure link the problem to that (timi...

formatting text as active hyperlinks
I have tried to format cells containing valid urls as hyperlinks. I can copy the format from a valid and active hyperlink; but when I paste it in the cell (I have tried pasting format), the contents look like a hyperlink, but the mouse cursor does not change when I hover over it, and I can't open the web site by clicking on it? Any ideas? -- dpimental ------------------------------------------------------------------------ dpimental's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=14848 View this thread: http://www.excelforum.com/showthread.php?threadid=26...

How To Show Drag Image while Dragging Item?
I use MFC 4.2. There are 2 CListCtrls in my app. I am implementing a drag and drop function from one list to another. How to show the drag image when I still choose which item that will accept the drop? Thank you. You can use a CImageList and store a drag image. Look at functions like CImageList ::BeginDrag, CImageList::BeginDrag | CImageList::EndDrag | CImageList::DragMove | CImageList::DragLeave. -Seetharam This article may be interesting to you. It's a little older, but it is still useful information: http://www.codeguru.com/cpp/controls/listview/dragdrop...

Deploy a DDL trigger to prevent dropping tables for mulitple datab
The SQL 2005 server I am using has mulitple databases. The database MyDB is one of them. I make a DDL trigger to prevent deleting columns in tables in MyDB. Here is the script to make the trigger: CREATE TRIGGER Safety ON DATABASE FOR ALTER_TABLE AS RAISERROR ('Table schema cannot be modified in database. You must disable Trigger "Safety" to drop or alter tables!', 16, 1); ROLLBACK ; The trigger works well for MyDB. Whenever deleting a column in a table inside MyDB, the transaction is not allowed. Now, I want to set up the same trigger not only mon...

export graphics & text to word or excel
Everytime I try to put my Publisher 2002 docment to Word or excel I get "goblty gook". I tried saving it as a jif, tif, bmp, etc. but none of them will open in Word or Excel 98. What am I doing wrong?????? I want to make a document with the post we made, plus a map, and a schedule and be able to e-mail it to people who do not have publisher. HELP!!! -- Ferret Mom Once you convert the Publisher document into an image, you then can insert it into the Word document. You can't open an image, you can view an image. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http:...

Populating a drop down list (attempt # 2)
Hi, I have a drop down list (list of clients) that the user can select from. I have a second drop down list, where I want the servers that belong to the client that was selected from the first drop down list (above) to be displayed. The second drop down box uses the following SQL: SELECT tbl_Perm_ServerName.ServID, tbl_Perm_ServerName.Client, tbl_Perm_ServerName.ServName FROM tbl_Perm_ServerName WHERE (((tbl_Perm_ServerName.Client)=[forms]![frm_ServBackupNam]![cmb_Client])) ORDER BY tbl_Perm_ServerName.ServName; When I run this SQL, it show the clients in both dropdown lists - can any...

text runs out of cell into other ones
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Just updated to X08 from Office. Some of cells with text in them (not wrapped) are overrunning the following cells, even when those cells have data in them, just showing a jumble of data on top of data. Clicking on the overrun cells makes the text on top go away (but it will remain in cells even farther down the road to the right), and it comes back. <br><br>It's a glitchy problem, not just a setting imho. It goes away if I &quot;wrap text&quot; on offending cell but then I can't...