C# Winforms: Resize and move control at runtime

Oct 3 2013 10:23 AM

Let's say you have a form (in winform project) with 2 controls (control1 and control2) arranged in a menu/detail fashion, so that control1 is a menu (occuping the left portion of the form) and control2 represents the detail (occuping the right, bigger portion of our form).

Now, when I click a button I want the menu to disappear, overlapped by the detail control (which of course increases its size to the left), when the button is pressed again the operation must be reversed. It would be nice if this may be done with a short transition animation which shows the detail control progressively increasing its size to the left, covering the menu.

Of course one can do this messing around with Control.Location and Control.Size, and probably even acquire a transition animation with a thread which progressively increases the size while forcing some repaints, but I was wondering if there's a faster - better - cleaner way to reach my goal.


Answers (1)