I am trying to do something very simple, which gives me huge problems in C # Winforms. I have two group fields in TabPage. One docked right and one docked bottom. I also have a chart on the page (System.Windows.Forms.DataVisualization.Charting). This graph is for Dock.Fill the remaining space on the page.
At first I ran into the problem of a chart hiding behind both group boxes, and a docking station filling the entire page. However, I found that I could solve this problem using "BringToFront" (or reordering the order of the document structure), and then the chart docked properly and did not overlap any other controls on the page.
However, I try to add a diagram to the page at runtime, and it fills the whole page again and hides behind other controls. How can I do this work?
EDIT: Forgot to mention, calling "BringToFront" will throw an exception "Width must be greater than 0px".
chart_TapChart = new Chart(); chart_TapChart.Dock = DockStyle.Fill; chart_TapChart.BringToFront(); GroupBox gp1 = new GroupBox(); gp1.Dock = DockStyle.Right; GroupBox gp2 = new GroupBox(); gp2.Dock = DockStyle.Bottom; this.Controls.Add(chart_TapChart); <--this refers to tabpage this.Controls.Add(gp1); this.Controls.Add(gp2);
source share