resize panels smoothly

C

Ching-Lung

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
 
B

Bob Powell [MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top