Link to home
Start Free TrialLog in
Avatar of mossman243
mossman243

asked on

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.

Thanks!
Avatar of Dmitry G
Dmitry G
Flag of New Zealand image

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?
Avatar of mossman243
mossman243

ASKER

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

ASKER CERTIFIED SOLUTION
Avatar of Dmitry G
Dmitry G
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial