Tuesday, October 07, 2008

winforms: Dock Fill is working wrong

I experienced much time with troubles in the C# windows form, if control is set dock:fill and I adding any other control (menu, status bar,whatever) to the form or panel.
In this case, main control with fill dock style doesn't recognize that need to fit, it overlapping any new control. Sometimes, to fix I creating new form and redesigned it from scratch.

Solution is very easy:
Right click on the control with fill dock style, and choose Bring to Front. Docking will be fixed :)

Source

9 comments:

Ant said...

Hahaha... I can't believe I've missed this for so long! Thanks :)

Anonymous said...

Thanks for your precious advice.

Anonymous said...

perfecto!!!!!!!! yo tambien hacia todo el formulario otra vez

Som Shekhar said...

this works perfect in the case of designer code. what to do if the controls are added at design time and the same problem reoccurs.

is there a way to do it by code?

The Last Don said...

Hi, Som!
Hmm... Apparently, when playing with the designer, it reorders things in the initializing code, but I didn't realized what exactly designer did with it, so I can't answer your question.

Sometimes to create user controls and include them in the form make things simpler.

Anonymous said...

Rather valuable message

Anonymous said...

Thanks for posting... Great help!!

Anonymous said...

Thank you very much! Couldn't find this information before.

Anonymous said...

Awesome! Thanks for this fix.