By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,357 Members | 1,021 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,357 IT Pros & Developers. It's quick & easy.

Visual effects with DragDrop

P: n/a
KS
I have a Button I want to pull to a Label.

I want the Button visualy to move when I pull it.

When I drop the button on the Label I want to test some data coming with the
Button - f.ex is the Button.Text="The right one!".

I have some code that can do the DragDrop-effect BUT this code disables the
visual effect og the Button visualy moving to the Label.

How can I combine the two effects so that when the Button is pulled it is
visualy moved AND when it's dropped on the Label - f.ex the Label.Text is
set to Button.Text ?

KS, Denmark
Nov 22 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
KS
I forgot - it's VB.NET 2002 !

KS, Denmark
Nov 22 '05 #2

P: n/a
Cor
Hi KS,

You can use for that one of the timers
(mostly I don't say that but I think for this system.forms.timer will do it)
(You can drag that from the windows.form toolbox on your form)
Set it to enable and set the tick to 1 or 2
And then use that to change the position on the form do in the timer.tick
event

Button1.Location = New Point(IntegerX, IntegerY)

And add then something (1 is enough) to the Integers in the direction you
want to let it go
(you have to do something for if you want to have it curves, but that is
just trying).

I think it looks nice?

Cor
....
I have a Button I want to pull to a Label.

I want the Button visualy to move when I pull it.

When I drop the button on the Label I want to test some data coming with the Button - f.ex is the Button.Text="The right one!".

I have some code that can do the DragDrop-effect BUT this code disables the visual effect og the Button visualy moving to the Label.

How can I combine the two effects so that when the Button is pulled it is
visualy moved AND when it's dropped on the Label - f.ex the Label.Text is
set to Button.Text ?

KS, Denmark

Nov 22 '05 #3

P: n/a
KS
Thanks for the idea but it don't work very well.

I want the button to follow the mousepointer and it seems as though the sign
for DragDrop-effect COPY is disabled by the following button - the COPY-sign
is momentarily to see ...

No, it don't look very nice.

KS, Denmark
Nov 22 '05 #4

P: n/a
Cor
HI KS

No, it don't look very nice.

With me it did

Cor
Nov 22 '05 #5

P: n/a
KS
It did ?

It LOOKs good enough but it wont work !

With me it looks like the 'following button' disables the
DragDrop-functions - the DragDrop just don't work !

KS
Nov 22 '05 #6

P: n/a
Cor
Hi KS,

If you dont send any part of code, it will be imposible to get an impression
what you are doing for others.

And not a total program but just the essentials.

Cor

With me it looks like the 'following button' disables the
DragDrop-functions - the DragDrop just don't work !

Nov 22 '05 #7

P: n/a
KS
I think I must accept NOT to visualy move the button while I'm pulling it
and then focus on getting the DragDrop to work - and it works fine !

But if I can drag and drop the Button as an OBJECT to the label I think I
can move the Button afterwards.

I know in this sample I just can reference the Button directly but in my
application I want to work on with the object that was DROPPED on the
label - the WHOLE object - how can I do that ?

In the MouseDown-event it IS posible to Drag an whole object - and CAN write
(without getting any syntax error):

Private Sub Button1_MouseDown(ByVal sender As Object, _
ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown
If e.Button = MouseButtons.Left Then
Button1.DoDragDrop(Button1, DragDropEffects.Move) ' Here it is -
the whole object Button1 !!!!!!!!!
End If
End Sub

But what skall I do in:

Private Sub Label1_DragEnter(ByVal sender As Object, _
ByVal e As
System.Windows.Forms.DragEventArgs) Handles Label1.DragEnter
If (e.Data.GetDataPresent(DataFormats.Text ) Then ' How shall I test if
the whole object is present ?
e.Effect = DragDropEffects.Move
End If
End Sub

And when I drop:

Private Sub label1_DragDrop(ByVal sender As Object, _
ByVal e As
System.Windows.Forms.DragEventArgs) Handles Label1.DragDrop
If e.Data.GetData(DataFormats.Text).ToString = "Button1" Then ' What
shall I write here ? - I think like this:
'If <dropped object>.text="Butten1" then
' but the <dropped object> is the problem !
' this CAN move the Button - but the Button is referenced directly
!!!
Button1.Location = PointToClient(MousePosition)
Button1.BringToFront()
' I'm think something like this:
' <dropped object>.Location = PointToClient(MousePosition)
' <dropped object>.BringToFront()
' but how can I get this <dropped object> ?
MessageBox.Show("Yes - it worked !")
End If
End Sub

Hope you can read my 'thinking' !

KS, Denmark
Nov 22 '05 #8

P: n/a
KS
Can or shall I just drag an drop a REFERENCE (or pointer) to the Button1 - I
think the .NET CAN do this for me - right ?

How ?

KS, Danmark

"KS" <ke************@os.dk> skrev i en meddelelse
news:ub**************@tk2msftngp13.phx.gbl...
I think I must accept NOT to visualy move the button while I'm pulling it
and then focus on getting the DragDrop to work - and it works fine !

But if I can drag and drop the Button as an OBJECT to the label I think I
can move the Button afterwards.

I know in this sample I just can reference the Button directly but in my
application I want to work on with the object that was DROPPED on the
label - the WHOLE object - how can I do that ?

In the MouseDown-event it IS posible to Drag an whole object - and CAN write (without getting any syntax error):

Private Sub Button1_MouseDown(ByVal sender As Object, _
ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown
If e.Button = MouseButtons.Left Then
Button1.DoDragDrop(Button1, DragDropEffects.Move) ' Here it is -
the whole object Button1 !!!!!!!!!
End If
End Sub

But what skall I do in:

Private Sub Label1_DragEnter(ByVal sender As Object, _
ByVal e As
System.Windows.Forms.DragEventArgs) Handles Label1.DragEnter
If (e.Data.GetDataPresent(DataFormats.Text ) Then ' How shall I test if the whole object is present ?
e.Effect = DragDropEffects.Move
End If
End Sub

And when I drop:

Private Sub label1_DragDrop(ByVal sender As Object, _
ByVal e As
System.Windows.Forms.DragEventArgs) Handles Label1.DragDrop
If e.Data.GetData(DataFormats.Text).ToString = "Button1" Then ' What shall I write here ? - I think like this:
'If <dropped object>.text="Butten1" then
' but the <dropped object> is the problem !
' this CAN move the Button - but the Button is referenced directly
!!!
Button1.Location = PointToClient(MousePosition)
Button1.BringToFront()
' I'm think something like this:
' <dropped object>.Location = PointToClient(MousePosition)
' <dropped object>.BringToFront()
' but how can I get this <dropped object> ?
MessageBox.Show("Yes - it worked !")
End If
End Sub

Hope you can read my 'thinking' !

KS, Denmark

Nov 22 '05 #9

P: n/a
Cor
Hi KS,

I cannot get what you are doing.
Are you trying to put a button on a label, so it can be pushed from that
label?

Or just the text from that button?

Cor
Nov 22 '05 #10

P: n/a
KS
I'm tring to drag a button to drop it on a label - when I depress the
mousebutton I
want some data from the button to be shown in a Msgbox (or just in the
label.text).

I can get the ordinary DragDrop sequense to function - but I think this
method is limited
to some text and some other types but NOT objects!

I want to drop a WHOLE OCJECT (or a pointer to an object) so that I can work
with THE WHOLE object
in the DragDrop-event.

In my simplefied sample code I 'think' it as a <dropped object> (in this
example a Button) so that I can do somethink like

<dropped object>.Location= new point(50,50)
<dropped object>.Text = "Just moved !"
ect
ect

instead of referencing the Button1 directly with Button1.Text="Just mobed !"

In the application where I plan to use this specified DragDrop-sequence I
can NOT reference the Button directly - that's why.

Do you get it ?

KS, Denmark
Nov 22 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.