Moving Objects in C#

Posted on 2008-11-18
Last Modified: 2012-05-05
Hello Experts,

I am relatively new to the C3/dot net world (have been in Java and legacy languages).  Can anyone give me a basic example (or point me to a really good article) describing how to dynamically move objects on a Form?

For instnace, I have 2 circles on the form.  When I move one circle down, I want the other circle to move down the same distance (so that they are right across from each other).  I would also like an example of how to move them in opposite directions of each other (whether by the same distance or random distance).

A client side example, along with a web based example, would be appreciated.

Question by:mossman243
    LVL 29

    Expert Comment

    I'd say the question is a bit vague. Is your circle an object? If you do not just draw this circle on a form but instead create a custom control, probably that's easier.

    Controls have a number of events that may help with the task, e.g. LocationChanged etc. If you drag a control with a mouse you may use MouseDown and MouseUp events etc.

    Could you pls state your task in more details?

    Author Comment

    Yes, I think a control might work.  If memory serves me correct from the old VB days, that was a method to do it.

    My task will eventually be to move several objects/controls to a location on the form based on the position of one object/control.  (i.e. if one object is in the top left corner, the other 2 objects are in the lower right corner, etc) Again, if memory serves me correct, I seem to remember having to calculate new xy coordinates for the dependent objects whenever the control object changed in VB, but I am not sure how to do this in C#.

    Hope this helps

    LVL 29

    Accepted Solution

    Really you task is not very simple one. I'd say, in Java it'd be probably easier.

    Anyway, look at:

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
    The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now