This one's really kicking my backside. I have a form, spawned and owned by the main form of the application, that is used for searching records. The form is laid out in a docked TableLayoutPanel, with a combination of Absolute and Percentage-sized rows/columns so that my labels stay the same size while the data entry and results controls grow. We're talking about 20 controls all told.
The problem is that, although the TableLayoutPanel is fill-docked, and all child controls are also fill-docked, nothing is resizing inside the form when I grab the window edge and drag. Everything resizes just fine in the designer, but not in the actual app.
I did use my Google-fu, and found this SO question which pointed me to this MSKB article. I created a derived FlowLayoutPanel and a derived TableLayoutPanel with the threaded calls and put them in, but it's still not working. This is the ONLY form on which this is happening, and another form has some pretty deep nesting as well (it uses a TabControl and TableLayoutPanel to layout the data entry controls, but no RBs).
Other pertinent info:
I'm tearing my hair out here. Help!
Edit: Here are some of the requested pictures showing layout behavior in the designer and in-app:
The controls that begin with "Nested" derive directly from the built-in panel controls, and their only change is an override of OnSizeChanged() to call the base method asynchronously (the workaround from the KB article). It doesn't work with the built-in panels either, as I said before. As you can see from the last two windows, the mainLayout TLP simply does not grow even though it's docked to the window in the designer.
Epic Facepalm.
In the constructor of this form (user code side), I called SuspendLayout()
to perform some additional setup that may affect the layout. Guess what I DIDN'T call when I was done.
If you call SuspendLayout to do your own custom layout changes, always be sure to call ResumeLayout(true)
(or ResumeLayout(false)
followed by PerformLayout()
) when you're done.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With