I'm trying to change the z-order for some docked panel in the VS2010 designer. However, everytime I save the designer, close it down and re-open it, the z-order has reverted back to how it was before I changed it.
I've tried using the document outline, and the SendToBack context menu but both behave in the same way. I've also noticed that in another solution where it does work, the .designer.cs file doesn't actually change (I assumed control adding order would dictate z-order).
Is there any other way I can do this? I really don't want to do this at runtime...
EDIT
this.mainPanel.BackColor = System.Drawing.SystemColors.Control;
this.mainPanel.Controls.Add(this.pnlRangeSelector);
this.mainPanel.Controls.Add(this.headerAndFooterRowCounts);
pnlRangeSelector has Dock.Top headerAndFooterRowCounts has Dock.Right
when this renders however, headerAndFooterRowCounts takes the entire right side of it's parent panel, while pnlRangeSelector takes the Left portion.
That suggests to me that the pnlRangeSelector isn't correctly at the back like it's supposed to be.
UPDATE
int i = 0;
String output = String.Empty;
foreach (var c in this.mainPanel.Controls)
{
if (c == pnlRangeSelector) { output += "RangeSelector at : " + i.ToString() + "\r\n"; }
else if (c == this.headerAndFooterRowCounts) { output += "HeaderAndFooter at : " + i.ToString() + "\r\n"; }
i++;
}
MessageBox.Show(output);
Seems the order is always RangeSelector = 0, HeaderAndFooter = 1. Even if I call the following just prior to this:
this.mainPanel.Controls.SetChildIndex(this.pnlRangeSelector, 1);
this.mainPanel.Controls.SetChildIndex(this.headerAndFooterRowCounts, 0);
The order in which the controls are added to the Controls collection of the parent determines the z-order. So the best way to solve this (AFAIK) is to make a backup of the designer file and then edit the order in which the controls are ADDED to the collection
Post the code if you need help.