Results 1 to 3 of 3

Thread: [RESOLVED] [2008] Change control location

  1. #1

    Thread Starter
    Lively Member mahammad()'s Avatar
    Join Date
    Jun 2008
    Location
    Cairo , Egypt
    Posts
    71

    Resolved [RESOLVED] [2008] Change control location

    Hi all

    How can I change control location (x,y)

    so when I click button the position (location property) will change

    thanks

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,419

    Re: [2008] Change control location

    vb Code:
    1. label1.location = new point(20,20)

    edit: do you mean you want to move the button when you click on it?
    its the same method anyway

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2008] Change control location

    Are you meaning like click on a coordinate on your form and the control moves to that location?

    If so just use the Form's Click event.

    Code:
    Option Explicit On
    Option Strict On
    
    Public Class Form1
    
        Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
            If e.Button = Windows.Forms.MouseButtons.Left Then
                Me.Button1.Location = e.Location
            End If
        End Sub
    
    End Class
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width