Norma Posy
asked on
Drag and drop between text boxes
VB6: I have two arrays of 8 text boxes each. The first is populated with texts. The second is all empty. I want to transfer the text from each of the first array to a different Indexed text box in the second array. (It saves a lot of typing, and possible typos.)
I tried a “drag and drop” using “mouse up” and “mouse down” events. Can’t seem to get it to work.
Dim sText as string
Source text box MouseDown event:
sText = txtBoxA(Index).text
Destination text box MouseUp event:
txtBoxB(Index).text = sText
What’s the secret here that I am missing?
Right now I am doing this using the click events. That requires the user to click, move the mouse, and click again. Drag and drop would be smoother.
I tried a “drag and drop” using “mouse up” and “mouse down” events. Can’t seem to get it to work.
Dim sText as string
Source text box MouseDown event:
sText = txtBoxA(Index).text
Destination text box MouseUp event:
txtBoxB(Index).text = sText
What’s the secret here that I am missing?
Right now I am doing this using the click events. That requires the user to click, move the mouse, and click again. Drag and drop would be smoother.
What you are asking for can probably be done, but would a simple "Transfer Data" button be better?
Set the OLEDragDrop property to 1 - Automatic on the text box from which you want to copy data, and set the OLEDropMode property to 2 - Automatic on the text box to which you want to copy the data.
ASKER
Martin:
This is a problem in re-ordering an eight-item list. It is to be done 60 times and it is tedious. I am trying to make it as easy for the user as possible. Your suggestion would take three actions: Identify the source, identify the destination, and click the "do it" button. Using click events only takes two clicks. Drag and drop would be even smoother.
Chris:
I set the OLEDragDrop properties as you suggested. Doesn't work.
I am not familiar with this property. Arguments for the MouseDown and MouseUp Subs now include four items, Button, Shift, X, and Y. Do these have anything to do with my intended drag-and-drop process?
What this is all about: This is a hairy combinatorial problem with strange restrictions and requirements. We gave up trying to automate it. We work it out with pencil and paper, then what I am trying to do here gets it into the main program.
This is a problem in re-ordering an eight-item list. It is to be done 60 times and it is tedious. I am trying to make it as easy for the user as possible. Your suggestion would take three actions: Identify the source, identify the destination, and click the "do it" button. Using click events only takes two clicks. Drag and drop would be even smoother.
Chris:
I set the OLEDragDrop properties as you suggested. Doesn't work.
I am not familiar with this property. Arguments for the MouseDown and MouseUp Subs now include four items, Button, Shift, X, and Y. Do these have anything to do with my intended drag-and-drop process?
What this is all about: This is a hairy combinatorial problem with strange restrictions and requirements. We gave up trying to automate it. We work it out with pencil and paper, then what I am trying to do here gets it into the main program.
No. You don't need any code after you set these properties. You can then drag and drop the contents of the text boxes from one to another. I'll attach a sample project when I'm back at my desk on Tuesday.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you. Note: I couldn't figure out how to split points. After I clicked "Best solution" I got locked out of picking another response and splitting points.
Remarks:
It occurred to me that this is going to be a lot of mouse action for the user, even with this slick drag and drop. Carpel Tunnel and all that. I may provide a keyboard key-stroke alternate method. But this way works fine as is.
Fortunately, this job has to be run only twice a year. This problem came from a desired improvement. The program itself is "legacy", and has been in use for many years. The whole thing really needs to be re-written from scratch in a modern language like C++. That's for somebody else. I'm too old.
- - Norma
Remarks:
It occurred to me that this is going to be a lot of mouse action for the user, even with this slick drag and drop. Carpel Tunnel and all that. I may provide a keyboard key-stroke alternate method. But this way works fine as is.
Fortunately, this job has to be run only twice a year. This problem came from a desired improvement. The program itself is "legacy", and has been in use for many years. The whole thing really needs to be re-written from scratch in a modern language like C++. That's for somebody else. I'm too old.
- - Norma
At 76 I'm kind of "legacy" myself:)
You're welcome and I'm glad I was able to help.
If you expand the “Full Biography” section of my profile you'll find links to some articles I've written that may interest you.
Marty - Microsoft MVP 2009 to 2017
Experts Exchange MVE 2015
Experts Exchange Top Expert Visual Basic Classic 2012 to 2017
You're welcome and I'm glad I was able to help.
If you expand the “Full Biography” section of my profile you'll find links to some articles I've written that may interest you.
Marty - Microsoft MVP 2009 to 2017
Experts Exchange MVE 2015
Experts Exchange Top Expert Visual Basic Classic 2012 to 2017