SuspendLayout, ResumeLayout() not called

E

Ethan Strauss

Hi,
I was just about to wrap some code for filling a DataViewGrid in
grid.SuspendLayout();
//Grid filling code
grid.ResumeLayout();
when I got worried t hat something might go wrong in the filling code and
ResumeLayout() would never get called. I considered putting ResumeLayout in a
finally block, but thought I would see what happens if I leave it out
completely. I tested the code with SuspendLayout and no ResumeLayout and I
don't see any problem at all!

What happens if ResumeLayout is not called? I assume it is being forced by
default somewhere. Would it be wiser to put all SuspendLayouted actions in
try blocks with ResumeLayout in finally blocks?

Thanks!
Ethan
 
M

Marc Gravell

I suspect it would get interesting if it was anchored / docked and you
start resizing the form. But best approach is finally. This is more
important for the BeginUpdate/EndUpdate type pairs, where rendering is
disabled.

Marc
 

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