Windows form - moving controls

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fayazmd
    New Member
    • Jul 2007
    • 41

    Windows form - moving controls

    Hi,
    I am creating an exe for which i need three conditions.
    1. The windows form should randomly move over the screen w.r.t. time
    2. A label on the form should move randomly w.r.t. time
    3. A button should be moved w.r.t. Mouse, On mouse over the button should be placed some where in the form.

    I am working in C# Windows App in .net 2003.
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    All of the objects you mentioned have coordinates that can be accessed and changed.
    Simple change them to what you want and they will move (you may have to call a .Update() on the control, or it's parent if you want to see better response time)

    Comment

    • fayazmd
      New Member
      • Jul 2007
      • 41

      #3
      Hi Plater,
      I am extremely sorry that i am new to this.
      Could you show me some sample codes for these conditions.

      Originally posted by Plater
      All of the objects you mentioned have coordinates that can be accessed and changed.
      Simple change them to what you want and they will move (you may have to call a .Update() on the control, or it's parent if you want to see better response time)

      Comment

      • Shashi Sadasivan
        Recognized Expert Top Contributor
        • Aug 2007
        • 1435

        #4
        The Location Property of the controls is what you are looking for !!!

        Comment

        • fayazmd
          New Member
          • Jul 2007
          • 41

          #5
          How can i change location property during run time with timer?

          Originally posted by Shashi Sadasivan
          The Location Property of the controls is what you are looking for !!!

          Comment

          • debasisdas
            Recognized Expert Expert
            • Dec 2006
            • 8119

            #6
            Originally posted by fayazmd
            How can i change location property during run time with timer?
            You need to assign random values to X and Y of location in the timer event.

            The random numbers should be in a particular range.

            Comment

            • fayazmd
              New Member
              • Jul 2007
              • 41

              #7
              Thanks!

              I got it.

              Originally posted by debasisdas
              You need to assign random values to X and Y of location in the timer event.

              The random numbers should be in a particular range.

              Comment

              Working...