Solved

VB6 Drag and Drop Label onto another Form

Posted on 2009-05-07
4
1,342 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now