cdoverlaw Posted August 20, 2004 Posted August 20, 2004 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 Quote
Administrators PlausiblyDamp Posted August 20, 2004 Administrators Posted August 20, 2004 imove.location.y=imove.location.y+1 .Equals is used for comparison not assignment. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
cdoverlaw Posted August 20, 2004 Author Posted August 20, 2004 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 Quote
Administrators PlausiblyDamp Posted August 20, 2004 Administrators Posted August 20, 2004 My bad - teach me to post code without running it. Try this instead Dim p as new Point(imove.Location.X,imove.Location.Y+1) imove.Location=p Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
*Experts* DiverDan Posted August 21, 2004 *Experts* Posted August 21, 2004 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. Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
Malfunction Posted August 21, 2004 Posted August 21, 2004 Hamburger1984 posted a nice class here: http://www.xtremedotnettalk.com/showthread.php?t=87180 It let's you move and resize your controls. Quote Debug me...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.