public void SetPaneIndex(DockPane pane, int index) { int oldIndex = Panes.IndexOf(pane); if (oldIndex == -1) { throw(new ArgumentException(Strings.DockPanel_SetPaneIndex_InvalidPane)); } if (index < 0 || index > Panes.Count - 1) { if (index != -1) { throw(new ArgumentOutOfRangeException(Strings.DockPanel_SetPaneIndex_InvalidIndex)); } } if (oldIndex == index) { return; } if (oldIndex == Panes.Count - 1 && index == -1) { return; } Panes.Remove(pane); if (index == -1) { Panes.Add(pane); } else if (oldIndex < index) { Panes.AddAt(pane, index - 1); } else { Panes.AddAt(pane, index); } }