954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Help With Moving Label For The User?

I am trying to make it so that the user can move anyone of the 10 Label box called "lblmovebox" onto any one of the top ten blank label box called "lbldropbox". So they can pick up any one of the "lblmovebox" and drag it onto anyone of the top ten blank label
"lbldropbox. When they move the "lblmovebox" to the "lbldropbox" I want the Caption to show up in the blank label box lbldropbox.


Example:

The top 4 deadliest spiders

1 blank label...... banana spidwer
"lbldropbox"........ "lblmovebox"

2 blank label...... sydney funnell webb
"lbldropbox2"........... "lblmovebox2"

3 blank label...... wofl spider
"lbldropbox3"... "lblmovebox3"

4 blank label...... black widow
"lbldropbox4"... "lblmovebox4"

So if they think the wofl spider is #1 they just click on the "lblmovebox3" and it can be move to the "lbldropbox", and if they want to take the "lblmovebox3" and move it to "lbldropbox2" they can! After they are done I will add up the score with a cmd button and show them the top 4 deadliest spiders, and show them what they put!

Thanks for your time

troblekid
Newbie Poster
10 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

I give example for drag and drop

> Place two label (Label1, Label2)
> Change DragMode Property of Label2 to 1 - Automatic
> And try the below code

Private Sub Label1_DragDrop(Source As Control, X As Single, Y As Single)
   If TypeOf Source Is Label Then
      Label1.Caption = Source.Caption
   End If
End Sub


Now try to learn how it works and solve your problem

selvaganapathy
Posting Pro
547 posts since Feb 2008
Reputation Points: 44
Solved Threads: 100
 

That's Just what I want! But I need to hide the Label2 after it has been moved! So when or how should I do the Label2.Visible=False? Only after they move it is when I want it to no show.

troblekid
Newbie Poster
10 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

Yes, Change the Visible property to false to the source control after making the drag operation.

selvaganapathy
Posting Pro
547 posts since Feb 2008
Reputation Points: 44
Solved Threads: 100
 

Thank You

troblekid
Newbie Poster
10 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

Ok it was going good tell I tryed to put the 3 label in the the 1 label box, then it took the 2 label and the 3 label and puting them both in the label 1 box. So it looks like I need a bit more help! I need 7 Named labels that can be moved to any of the 7 blank labels in any order. I hope this makes sence! lol

troblekid
Newbie Poster
10 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

Check the Caption of the Label
> If it is empty then perform the drag operation (that is Change the Caption)
> Otherwise Dont do the Drag Operation

OR

> Make Enabled Property of the Target Control (Label that receive DragDrop operation) to False.

These both prevent the multiple Drop operation for one Control.

selvaganapathy
Posting Pro
547 posts since Feb 2008
Reputation Points: 44
Solved Threads: 100
 

I tryed doing the Make Enabled Property of the Target Control (Label that receive DragDrop operation) to False. It was still doing the same thing, I don't know how to do the line of code that well check the caption of the label and well change the captiion option do you have some code lines that could help me?

troblekid
Newbie Poster
10 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

Make Enabled property of Target Control is working.
Consider the Above coding

Private Sub Label1_DragDrop(Source As Control, X As Single, Y As Single)
   If TypeOf Source Is Label Then
      Label1.Caption = Source.Caption
      Label1.Enabled = False
   End If
End Sub


Or
Another possiblity you are having blank Labels as target. So if the label's caption is blank then only it receives drag drop event.

Private Sub Label1_DragDrop(Source As Control, X As Single, Y As Single)
   
   If Label1.Caption = "" And TypeOf Source Is Label Then
      Label1.Caption = Source.Caption
   End If
End Sub
selvaganapathy
Posting Pro
547 posts since Feb 2008
Reputation Points: 44
Solved Threads: 100
 

I figer out what I was doing wrong, I was trying to multiple code in the DragBox. lol

Ok I am useing the
Private Sub Label1_DragDrop(Source As Control, X As Single, Y As Single)
If Label1.Caption = "" And TypeOf Source Is Label Then
Label1.Caption = Source.Caption
End If
End Sub

How can I tell the code, after useing the Source to make the Source that was used to be Visible = False?

I am thinking of somthing like

Private Sub Label1_DragDrop(Source As Control, X As Single, Y As Single)
If Label1.Caption = "" And TypeOf Source Is Label Then
Label1.Caption = Source.Caption
Then Source.Visible = False
End If
End Sub

But of course it wont let me! lol

troblekid
Newbie Poster
10 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

It is correct, just change

Private Sub Label1_DragDrop(Source As Control, X As Single, Y As Single)
   If Label1.Caption = "" And TypeOf Source Is Label Then
      Label1.Caption = Source.Caption
      Source.Visible = False
   End If
End Sub
selvaganapathy
Posting Pro
547 posts since Feb 2008
Reputation Points: 44
Solved Threads: 100
 

You saved the day once more!! Thanks for all you help!!

troblekid
Newbie Poster
10 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You