views:

738

answers:

3

I've encountered an issue with the ordering of docked UserControls. I have 2 that are docked to "Top", and the order that they appear is the opposite of what I wanted.

What I've tried:

  • I tried reversing the order in the .Designer.cs to make it work, and while that worked in the UI Designer, it reverted while running!
  • I've also tried deleting the controls and adding them in various orders back to the form. This didn't work either.

This is in C# 2.0, VS 2008.

How can I resolve this docking problem?

Thanks, Sean

+1  A: 

You could drop the first control into the form, dock it to Top, then add a panel control, dock it to fill, then add your second control to the panel and dock it to the top of the Panel.

Rob Prouse
A: 

Well, I played around with the designer code some more, put all of the second control's initialization before the first control's, and made the TabIndex of the first less than the second, and reapplied the docking and I got it to work.

This is a weird issue, and I'm afraid to touch anything and make it worse!

torial
+4  A: 

In the .Designer.cs file, you reversed the order of the this.Controls.Add(usercontrol1) lines near the bottom of the file, right? Usually it's just the order that the controls are added to the form that matters. The initialization code doesn't actually add it to the form.

Nicholas Piasecki