Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB6 Drag and Drop Label onto another Form

Posted on 2009-05-07
4
Medium Priority
?
1,421 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
Antagony1960 earned 75 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 75 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

660 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