Moving Objects in C#

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.

Who is Participating?
anarki_jimbelConnect With a Mentor Commented:
Really you task is not very simple one. I'd say, in Java it'd be probably easier.

Anyway, look at:
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?
mossman243Author Commented:
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

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.