Stec Records Forum

Tools to make music

News: Note that we check all new user requests for spam violations. If you believe you have been rejected unfairly please contact us and we will attempt to resolve it with you. - Stecrew

Docked custom controls don't resize themselves to fit TabPage (Read 5420 times)

  • Administrator
  • Hero Member
  • bob
  • Posts: 773
  • Karma: +0/-0
  • Time reveals truth.
    • Bob Sellon's Home Page
OK, the AutoScaleMode got me again. This time just saving and restoring sizes for my custom Controls. In my test case, the AutoScaleMode was increasing the dimensions slightly throwing the whole layout off.

"If you are having trouble getting C# Forms to be manually re-sized, set AutoScaleMode to None. "

I eventually want to use AutoScaleMode in a few places but for now I'm avoiding it.

  • Administrator
  • Full Member
  • Lexicon Repairs
  • Posts: 120
  • Karma: +0/-0
  • Stec Records Forum PD
    • The Jukeyard
Geez Bob it seems sometimes the biggest problem can be just a small thing. Finding that needle in the hay stack is what separates the men from the boys. Good work Bob, it's actually coming together now.
Mapex Pro M Maple standard, Pearl 800 series cymbal stands, Vex hi hat stand, Pearl P201P double bass pedals, Tama mid level throne, All Zildjian A cymbals, 21" Rock Ride, 18" med thin crash, 16" med thin crash, 10" splash, 14" new beat hi hats.

  • Administrator
  • Hero Member
  • bob
  • Posts: 773
  • Karma: +0/-0
  • Time reveals truth.
    • Bob Sellon's Home Page
My last post was a partial red herring. In my case, the problem ended up being the AutoScaleMode on the custom controls being set for Font. When I changed them to None, the control contents re-size themselves appropriately. 

  • Administrator
  • Hero Member
  • bob
  • Posts: 773
  • Karma: +0/-0
  • Time reveals truth.
    • Bob Sellon's Home Page
This "forms" problem was driving me crazy and took hours to figure out. Hopefully this post will save someone some time.

My app had a tab control that I was dynamically adding custom controls to at start up. I was setting the Dock on the custom control to Fill but when the control showed up in the tab page, the size of the control was off, either getting cut off or too small.  If I resized the window or split that the tab was in, the custom control in a tab page would resize but still be cut off. 

After countless failed attempts to trick the control into resizing itself, I found a Windows Forms Online Library (http://flylib.com/books/en/3.59.1.36/1/) that discussed the details of the Docking process and how z-order affected what the control was actually docking to.  I was able to get the custom controls to resize themselves properly by adding a call to UpdateZOrder() on the custom control after it was added to the tab page.