Solved

VB6 Drag and Drop Label onto another Form

Posted on 2009-05-07
4
1,379 Views
Last Modified: 2013-12-26
Hi.
VB6.  I have a Label on a PictureBox on Form1 which I want to Drag and Drop onto a PictureBox on a separate Form2.  I get error message 425 Invalid object use.  Dragging and Dropping the label from one PictureBox to another on the same Form1 works OK.
TIA.

EDIT: This is not a Drag and Drop problem, it's the Container property.  It looks like the 'Container' has to be on the same Form as the Source.  Is there a way round this?

Code for Form1:
Private Sub Form_Load()
  Form2.Show
End Sub

Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  Label1.Drag vbBeginDrag
End Sub

Code for Form2:
Private Sub Picture1_DragDrop(Source As Control, X As Single, Y As Single)
  Set Source.Container = Picture1
  Source.Drag vbEndDrag
End Sub
0
Comment
Question by:Sat2b
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
Antagony1960 earned 25 total points
ID: 24335120
You can only change the container property of an object within the form in which it has been created. To drag between forms you have to create a matching object on the target form and change the visibility of the two objects accordingly.
0
 
LVL 1

Assisted Solution

by:mystami
mystami earned 25 total points
ID: 24346737
Therefore basically if you drag and drop it to the main area on your original form, then you will be able to drag that new one and drop it to the new form in the main area.  Because neither will have any containers at that point.
0
 

Author Closing Comment

by:Sat2b
ID: 31578912
Thanks guys, I dropped the label info into a FlexGrid in the end.
0
 

Author Comment

by:Sat2b
ID: 24383509
Thanks Guys.

I added a FlexGrid to the second Form, Dropped the Label info into a cell and made the Label invisible on the first Form.  Probably works better than how I'd planned to do it with the Label!

Cheers.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How does CurrentUser work? 10 41
Help me. 3 68
vbModal 12 65
VBA - Excel, Hide/unhide range of rows on sheet with listbox selection 9 95
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question