views:

419

answers:

4

Hi,

I have a tabcontrol on my form, on each tab I have a control, each of these controls are similar i.e. they each have a table and a couple buttons and each control is set to Dock Fill

When I view them contols in design view something weird is happening, the first tab that is viewable has it controls placed as you would expect and all is fine, but the second and third tab each the controls appear off centre, overlapping the edges of the tab.

I have experimented with placing different controls on different tabs and it appears that if a control is on the first tab it appears fine, if it is on any other it sometimes appears weird.

The really big problem is that this seems to be appearing at run-time as well, but only sometimes.

I've checked the properties of the controls and the tabs but all seems to be the same.

Any advice would be much appreciated.

Kind regards

MeeM

A: 

Seems like a bug to me, make sure you have all the latest updates for Visual Studio.

James
I've checked and I do have the latest updates.
MeeM
A: 

Is this a UserControl that you are placing on a tab? If so, I would check all the layout properties on the user control and the child controls inside the user control. I have had this problem before, but I can't remember off had what I did to fix it.

joek1975
A: 

Try this:

  1. First thing is to verify the z-order of your controls is correct. For that open your Document Outline window (View->Other Windows->Document Outline) and visually check for the order of each control one by one. When setting the docking properties of controls the z-order of the controls is applied in reverse; that is: the first child control shown in the document outline has docking precedence over those at the same level lower in the document outline window.

  2. Verify that no 2 child controls of the same parent (in your case the tabControl) have the DockStyle.Fill. As a good practice with docking, only one of the child controls should have its docking set to Fill. If you have this case it is most likely rethinking your layout flow will allow you to change it and have only one with Fill. The other docking styles (right, left, top, bottom) can be used in more than one child control and they'll never cause any problems. Only Fill is the problematic one.

  3. If 1 nor 2 solved your problem, my advice if to avoid docking altogether and use Anchoring instead. You can essentially get very similar results using the Anchor property of the controls. I actually like this approach more, since is kinda similar to WPF anchoring.

  4. If 1, 2 not 3 solve your problem. Post an image with your document outline and I'll recreate it here, fix it and post the solution here.

Hope it helped!

Michel Triana
A: 

I assume that these are user controls we are talking about. Have you changed the layout of the control (class) itself since you added the user controls into your tabs? If so, they will not automatically update with the new value (for Dock, width, height, etc.).

Ed Swangren