TabPage, Panel, and AutoScaleMode

  • Thread starter Thread starter Nathan
  • Start date Start date
N

Nathan

This is to redirect my earlier question about the designer and .NET CF 2.0.

I've found out more.

It seems that the trouble is that the Panel Control and TabPage Control
don't respond to AutoScaleMode. In fact, they behave quite unpredictably in
the designer.

Looking at the hierarchy, it is apparent that Panel and TabPage inherit from
Scrollable Control, and not ContainerControl. Not sure why, since they are
definitely containers for other controls.

I can't be the only one who has run into this. What is a suitable
workaround? Is there a control I should use that is like a Panel, but has
the important AutoScaleMode property? Non of the descendents seem to be in
the toolbar.

Maybe a custom control is what you'll suggest. I don't want to reinvent the
wheel, so if it has already been solved, I want to learn from that.

Nathan
 
For future generations, I am posting the steps I've taken

Editing the code to replace all instances of Panel with an instance of user
control will cause them to work correctly. The steps are
1. Set form's AutoScaleMode = dpi
2. Edit code to replace Panel with UserControl. (UserControl won't show up
in the toolbox, at least for me.)

Fixing Tabpages was a bit more complex.
1. Set form's AutoScaleMode = dpi
2. Set tabControl's Dock=Fill (could depend on your tabpage's location.
3. Change to VGA mode. The controls in the tabpages will not scale up,
giving you more room to work. 4. Create a Panel in the empty space of a
tabpage
5. Select all controls from the tabpage and place them into the Panel,
maintaining their relative position.
6. Set the Panel's Dock=Fill
7. Repeat steps 4-6 for all tabpages.
8. Edit the code, replacing all instances of Panel with UserControl.

Doing this for a brand new form may not be so cumbersome, but you should
remember to add a UserControl to each TabPage before placing anything on/in
it.

Nathan
 
Back
Top