Wednesday, June 18, 2008

Disappearing Controls in the Left SplitContainer Panel when using Large Fonts

I have been experiencing a strange problem that I have finally confirmed as a bug in the .NET Framework 2.0. If you are using a SplitContainter and place controls in your Left panel, then if you anchor those controls to the Right or the Bottom, they will disappear when you run the app on a machine that is using Large Fonts. My controls happen to all be in a group box, but I don't think that matters. The controls disappear because the anchor is setting the height and/or width to 0 and they are not visible. If you can drag the size wide or tall enough, the controls will start to appear, but they scaling is off and the anchor is not working correctly. If using Small Fonts, this problem does not exists.

I found a few other people with the same problem, but no solutions. I found one suggestion to do a Refresh on the Splitter move event, but this did not help me. My solution has been to adjust the size of the controls in the left panel myself and not rely on the anchor. Please post a comment if you have a better solution to this problem.


Anonymous said...

Not just the left panel. All the panel experience the similar issues. If you cause any of the panel to collaspe and reshow, all the anchor controls goes on rampage and appears in all sorts of formation.

srego said...

Yes, I have since confirmed that it can be either panel in the SplitContainer. However, I do not have to callapse and reshow for the anchors to go whacky. They are whacky from the beginning if Large Fonts are used.

Sanvb said...

I am using SplitContainer in 2005, I am facing one problem.
I am rotating the SplitContainer by changing the orientation at run time, but whenever I rotate, all control's position got changed even though I mentioned control's left and top at runtime.

is there any solution?
I appiciate if any solution

Ben H said...

I think I found a fairly simple workaround for the split container large font issue.

Put your controls into two new instances of panel. Put each new panel in the splitter, then set dock to fill. You end up with a nested panel in each pane of the splitter. This works because split container doesn't have a problem with dock and panel doesn't have a problem with anchors.

Some people reported that collapsing a panel caused the same issues. It's possible this solution would work there as well (nest a docked panel into a collapsing panel), but I have not tested it.