private void PrepareTabPages() //Loop through the tabpages and create 2 panels per tabpage { for (int Tabcount = 0; Tabcount <= TabCtrl.TabCount - 1; Tabcount++) { CreateBottomPanel(Tabcount); //Create a panel per tabpage CreateChartPanel(Tabcount); } } private void CreateBottomPanel(int Tabcount) { Panel BottomPanel = new(); BottomPanel.Name = "BottomPanel"; BottomPanel.Text = string.Empty; BottomPanel.Location = new Point(3, 50); BottomPanel.Size = new Size(50, 32); BottomPanel.BackColor = Color.Firebrick; PlaceControleOnSpltcontainerOne(BottomPanel, Tabcount); } private void CreateChartPanel(int Tabcount) { Panel ChartPanel = new(); ChartPanel.Name = "ChartPanel"; ChartPanel.Text = string.Empty; ChartPanel.Location = new Point(3, 50); ChartPanel.Size = new Size(50, 32); ChartPanel.BackColor = Color.ForestGreen; ChartPanel.BorderStyle = BorderStyle.Fixed3D; PlaceControleOnSpltcontainerOne(ChartPanel, Tabcount); } private void PlaceControleOnSpltcontainerOne(Control NewCntrl, int Tabcount) { TabPage tp = TabCtrl.TabPages[Tabcount]; foreach (Control c in tp.Controls) { if (c.GetType() == typeof(SplitContainer)) //is a splitcontainer { SplitContainer splt2 = (SplitContainer)c; splt2.Panel2.Controls.Add(NewCntrl); if (NewCntrl.Name == "BottomPanel") { NewCntrl.Dock = DockStyle.Bottom; } if (NewCntrl.Name == "ChartPanel") { NewCntrl.Dock = DockStyle.Fill; } } } }