void DoChangePanel(object state) { // remember which tab we were on int topTabIndex = this.advancedControlsTabControl.SelectedTabIndex; // remove the advance control and replace it with new ones build for the selected printer int advancedControlsWidgetIndex = Panel2.GetChildIndex(this.advancedControlsTabControl); Panel2.RemoveChild(advancedControlsWidgetIndex); this.advancedControlsTabControl = CreateNewAdvancedControlsTab(sliceSettingsUiState); Panel2.AddChild(this.advancedControlsTabControl, advancedControlsWidgetIndex); // set the selected tab back to the one it was before we replace the control this.advancedControlsTabControl.SelectTab(topTabIndex); // This is a hack to make the pannel remain on the screen. It would be great to debug it and understand // why it does not work without this code in here. RectangleDouble localBounds = this.LocalBounds; this.LocalBounds = new RectangleDouble(0, 0, this.LocalBounds.Width - 1, 10); this.LocalBounds = localBounds; }