0

I have a form which has a RichTextBox docked to the left and DataGridView docked to the right. RTB is set to readonly. I'm trying to implement a special drag and drop feature where if the user holds the mouse down on a special keyword, it creates a textbox on top of the keyword which the user can drag to the DGV to drop the textbox off. When the textbox is successfully dropped off on the DGV, the DGV loads some information about the keyboard.

Although I can just easily capture the mousedown & mousemove event on the form itself to implement the above feature, I feel like using the mousemove event to consistently update the position of the textbox is a very inefficient way of approaching this problem and will result in poor performance. I'd like to hear any better ideas about handling the above problem. Thans.

Ken White
  • 123,280
  • 14
  • 225
  • 444
TtT23
  • 6,876
  • 34
  • 103
  • 174
  • This is almost a duplicate of [this question](http://stackoverflow.com/questions/495666/c-sharp-drag-drop-from-listbox-to-treeview?rq=1), with the only difference being you're using a `RichTextBox` and `DataGridView` instead of a `ListBox` and `TreeView`. – Ken White Jun 22 '12 at 01:09
  • It's also creating a textbox, which is actually the fundamental object that gets dragged. Pretty different from that example in my opinion. – TtT23 Jun 22 '12 at 01:20
  • Um, no. It isn't, unless you're not willing to do *anything* at all to the code. It would take minimal effort to implement the change you want. – Ken White Jun 22 '12 at 01:22
  • Winforms presents an easy way to implement drag and drop between controls. Here's a link to a very complete tutorial. You can easily transpose it to your needs. http://www.codeproject.com/Articles/3760/How-to-implement-simple-drag-and-drop-functionalit – Samy Arous Jun 22 '12 at 01:10

1 Answers1

2

Yes your right about that, you need to use DoDragDrop, search on that it will fill your google search with relative stuff.

Orn Kristjansson
  • 3,435
  • 4
  • 26
  • 40
  • This is not an answer to the question. It's a comment on the fact the poster is asking a question. Answers posted should do exactly that - provide an actual answer to the question asked. This is at best a comment, and it's really not even that; it's more of a statement saying "You're right. That's what you need. Google it." – Ken White Jun 22 '12 at 01:25
  • Hmm, the answer is use the DoDragDrop function, are you saying that's wrong ? – Orn Kristjansson Jun 22 '12 at 01:30
  • I'm saying that a single sentence saying "Google this word" is not an answer, and that's what you provided. – Ken White Jun 22 '12 at 22:16