Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi, i want to make the user able to move the controls, ive been testing this with a control called imove (its a button)

With imove.Location.Y
           .Equals(.Equals + 1)
End With

This doesent work, this is the error

 

F:\Documents and Settings\Jonathan\My Documents\Visual Studio Projects\Test100\Form1.vb(111): Overload resolution failed because no accessible 'Equals' accepts this number of arguments.

 

So how do i make it so the control can be moved

 

 

Jonathan

Posted

F:\Documents and Settings\Jonathan\My Documents\Visual Studio Projects\Test100\Form1.vb(111): Expression is a value and therefore cannot be the target of an assignment.

 

This error is caused by that

  • *Experts*
Posted

Do you want to move the control only 1 pixel, or be able to move the control anywhere on the form?

 

To move the control anywhere on the form with the mouse try this:

 

Globally declare x & y as integers

Dim x, y as Integer

 

then:

   Private Sub myControl_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles myControl.MouseDown
       x = myControl.PointToClient(Me.Cursor.Position).X
       y = myControl.PointToClient(Me.Cursor.Position).Y
       myControl.BringToFront()
   End Sub

   Private Sub myControl_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles myControl.MouseMove
       If e.Button = MouseButtons.Left Then 'you can also use MouseButtons.Right 
           Dim pt As Point
           pt.X = Me.PointToClient(Me.Cursor.Position).X - x
           pt.Y = Me.PointToClient(Me.Cursor.Position).Y - y
           myControl.Location = pt
       End If
   End Sub

where myControl is the control you wish to move.

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...