Home All Groups Group Topic Archive Search About

How to drag a form around the screen?

Author
6 Jul 2006 6:02 PM
Blarneystone
Hi,

I am wanting to code a way to drag a form around the screen - but can't
remember how to do this in vb.net.

Can someone please post a code snippet?

Thanks

Author
6 Jul 2006 6:43 PM
Blarneystone
ooops...I found it..

For anyone who's interested:

    Private MouseDownLoc As Point

    Private Sub pb_T_Title_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles pb_T_Title.MouseDown
        MouseDownLoc.X = e.X
        MouseDownLoc.Y = e.Y
    End Sub

    Private Sub pb_T_Title_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles pb_T_Title.MouseMove


        If e.Button = MouseButtons.Left Then
            Me.Left += e.X - MouseDownLoc.X
            Me.Top += e.Y - MouseDownLoc.Y
        End If


    End Sub


Blarneystone wrote:
Show quoteHide quote
> Hi,
>
> I am wanting to code a way to drag a form around the screen - but can't
> remember how to do this in vb.net.
>
> Can someone please post a code snippet?
>
> Thanks
Author
6 Jul 2006 8:53 PM
zacks
Blarneystone wrote:
> Hi,
>
> I am wanting to code a way to drag a form around the screen - but can't
> remember how to do this in vb.net.
>
> Can someone please post a code snippet?
>

Why would you want to do this in VB? Windows does it for you.
Author
6 Jul 2006 11:48 PM
gene kelley
On 6 Jul 2006 13:53:33 -0700, za***@construction-imaging.com wrote:

>
>Blarneystone wrote:
>> Hi,
>>
>> I am wanting to code a way to drag a form around the screen - but can't
>> remember how to do this in vb.net.
>>
>> Can someone please post a code snippet?
>>
>
>Why would you want to do this in VB? Windows does it for you.

Borderless Form (No TitleBar) is the usual reason.

Gene