G
Guest
Hello everyone,
I have a tab control in which I've created a tab page. I add a GroupBox to
the page and add two buttons to the GroupBox. So far so good, everything
works. Then, I add a second GroupBox below the first, and try to add some
controls to that, but only the GroupBox appears, never the controls. The
first group box continues to display just fine. What could be the problem?:
Code:
// Add the first tab page ("Axes"):
TabPage axesPage = new TabPage("Axes");
tabControl1.TabPages.Add(axesPage);
// Add the controls to the tab page.
// Add the group box to frame the font buttons:
GroupBox fontFrame = new GroupBox();
fontFrame.Location = new Point(axesPage.Left+15, axesPage.Top+10);
fontFrame.Width = 300;
fontFrame.Height = 75;
// Add the fontFrame to the page:
axesPage.Controls.Add(fontFrame);
// Add the "X-axis font" button to the group box:
Button xAxisFontButton = new Button();
xAxisFontButton.Text = "X-axis font...";
xAxisFontButton.Location = new Point(fontFrame.Left + 10, fontFrame.Top+12);
xAxisFontButton.Width = 120;
xAxisFontButton.Height = 35;
// Add the button to the group box:
fontFrame.Controls.Add(xAxisFontButton);
// Add the "Y-axis font" button:
Button yAxisFontButton = new Button();
yAxisFontButton.Text = "Y-axis font...";
yAxisFontButton.Location = new Point(fontFrame.Left + 140, fontFrame.Top+12);
yAxisFontButton.Width = 120;
yAxisFontButton.Height = 35;
// Add the button to the page:
fontFrame.Controls.Add(yAxisFontButton);
// Add the group box to frame the axes labels:
GroupBox labelFrame = new GroupBox();
labelFrame.Location = new Point(axesPage.Left+15, axesPage.Top+105);
labelFrame.Width = 300;
labelFrame.Height = 75;
// Add the labelFrame to the page:
axesPage.Controls.Add(labelFrame);
// Add the axes title labels:
Label xAxisLabel = new Label();
xAxisLabel.Text = "X-axis label:";
xAxisLabel.Location = new Point(labelFrame.Left+25, labelFrame.Top+20);
xAxisLabel.Width = 80;
Label yAxisLabel = new Label();
yAxisLabel.Text = "Y-axis label:";
yAxisLabel.Location = new Point(labelFrame.Left+25, labelFrame.Top+50);
yAxisLabel.Width = 80;
// Add the labels to the group box:
labelFrame.Controls.Add(xAxisLabel);
labelFrame.Controls.Add(yAxisLabel);
- "labelFrame" is visible and properly placed, but the controls that were
added to it are not visible. What is going on here? Thanks!
I have a tab control in which I've created a tab page. I add a GroupBox to
the page and add two buttons to the GroupBox. So far so good, everything
works. Then, I add a second GroupBox below the first, and try to add some
controls to that, but only the GroupBox appears, never the controls. The
first group box continues to display just fine. What could be the problem?:
Code:
// Add the first tab page ("Axes"):
TabPage axesPage = new TabPage("Axes");
tabControl1.TabPages.Add(axesPage);
// Add the controls to the tab page.
// Add the group box to frame the font buttons:
GroupBox fontFrame = new GroupBox();
fontFrame.Location = new Point(axesPage.Left+15, axesPage.Top+10);
fontFrame.Width = 300;
fontFrame.Height = 75;
// Add the fontFrame to the page:
axesPage.Controls.Add(fontFrame);
// Add the "X-axis font" button to the group box:
Button xAxisFontButton = new Button();
xAxisFontButton.Text = "X-axis font...";
xAxisFontButton.Location = new Point(fontFrame.Left + 10, fontFrame.Top+12);
xAxisFontButton.Width = 120;
xAxisFontButton.Height = 35;
// Add the button to the group box:
fontFrame.Controls.Add(xAxisFontButton);
// Add the "Y-axis font" button:
Button yAxisFontButton = new Button();
yAxisFontButton.Text = "Y-axis font...";
yAxisFontButton.Location = new Point(fontFrame.Left + 140, fontFrame.Top+12);
yAxisFontButton.Width = 120;
yAxisFontButton.Height = 35;
// Add the button to the page:
fontFrame.Controls.Add(yAxisFontButton);
// Add the group box to frame the axes labels:
GroupBox labelFrame = new GroupBox();
labelFrame.Location = new Point(axesPage.Left+15, axesPage.Top+105);
labelFrame.Width = 300;
labelFrame.Height = 75;
// Add the labelFrame to the page:
axesPage.Controls.Add(labelFrame);
// Add the axes title labels:
Label xAxisLabel = new Label();
xAxisLabel.Text = "X-axis label:";
xAxisLabel.Location = new Point(labelFrame.Left+25, labelFrame.Top+20);
xAxisLabel.Width = 80;
Label yAxisLabel = new Label();
yAxisLabel.Text = "Y-axis label:";
yAxisLabel.Location = new Point(labelFrame.Left+25, labelFrame.Top+50);
yAxisLabel.Width = 80;
// Add the labels to the group box:
labelFrame.Controls.Add(xAxisLabel);
labelFrame.Controls.Add(yAxisLabel);
- "labelFrame" is visible and properly placed, but the controls that were
added to it are not visible. What is going on here? Thanks!