Hi,

I have a windows form with a button and 2 panels. All
Panel.Dock = DockStyle.Left

-------------
| | |
| 1 | 2 |
| | |
-------------

When I click on the button, I want panel 1 to shrink and
panel 2 to grow in width:

int i = p1.Width;
p1.Width = p2.Width;
p2.Width = i;
this.Refresh();

My question is... how to make the shrinking and growing
animation look smooth and not flickering on the monitor?

I tried to use timer, but it's completely unacceptable
for user's experience.

Please help!

Thanks,
Ching-Lung

Re: resize panels smoothly by Bob

Bob
Fri Aug 01 04:41:46 CDT 2003

The flickering is probably due to the fact that the panel's
OnPaintBackground cannot be turned off. Consider deriving a class from panel
that prevents this from happening either by setting the appropriate control
styles or by overriding the OnPaintBackground method to do nothing.

--
Bob Powell [MVP]
C#, System.Drawing

Check out the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Buy quality Windows Forms tools
http://www.bobpowell.net/xray_tools.htm

New Tips and Tricks include creating transparent controls
and how to do double buffering.

"Ching-Lung" <chinglung@alumni.cs.utexas.edu> wrote in message
news:038701c3579b$8aafcbb0$a301280a@phx.gbl...
> Hi,
>
> I have a windows form with a button and 2 panels. All
> Panel.Dock = DockStyle.Left
>
> -------------
> | | |
> | 1 | 2 |
> | | |
> -------------
>
> When I click on the button, I want panel 1 to shrink and
> panel 2 to grow in width:
>
> int i = p1.Width;
> p1.Width = p2.Width;
> p2.Width = i;
> this.Refresh();
>
> My question is... how to make the shrinking and growing
> animation look smooth and not flickering on the monitor?
>
> I tried to use timer, but it's completely unacceptable
> for user's experience.
>
> Please help!
>
> Thanks,
> Ching-Lung
>