Solved

VB6 Drag and Drop Label onto another Form

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 7 hours left to enroll

623 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