Swap values of two textboxes using drag and drop
-
I'm very new to .net .... any help is much appreciated! I'm using vb.net and visual studio.net to build a form. This form has two textboxes (textbox1 and textbox2). I'm trying to drag and drop the value of textbox2 into textbox1. Further, after the drop, I went textbox2 to retain the value of textbox1. A swap. See illustration below: Figure 1 - The initial state of both textboxes Textbox1 Textbox2 15 37 Figure 2 - The state of the textboxes after the drag and drop Textbox1 Textbox2 37 <----- 15 So far, I've gotten this to work: Textbox1 Textbox2 37 <----- 0 I've debugged what I've done so far, and checked the call stack. What's happing so far is: 1. The mousedown event occurs on textbox2. This even triggers the drag and drop event of textbox1 2. In the textbox1.drag_and_drop(), I've added some code to set textbox1.text = 3. Control is returned back to textbox2.mousedown() where I set textbox2.text = 0 I've tried overloading the procedure textbox1.drag_and_drop() to include a 3rd, byRef, argument oldValue as String, that I set to the original value of textbox1.text. However this doesn't compile because textbox1.drag_and_drop() HANDLES dragdrop. My question is this: What's the easiest way of getting this done? If I'm going down the right road, how do I overload the dragdrop event so that I can implement this 3rd argument? If I overload the event, do I need to recreate all the code associated with dragdrop?