Hello,
I have a form with a UserControl inside it, and inside that UserControl is a GroupBox:
Under certain conditions, I want to add another GroupBox below the first one. When those conditions are met, I add it dynamically as the following code snippet from the UserControl shows:
RevisionGroupBox.Dock = DockStyle.Top;
_newRevisionGroupBox = new GroupBox();
_newRevisionGroupBox.Text = "New Project Revision";
_newRevisionGroupBox.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
_newRevisionGroupBox.Dock = DockStyle.Bottom;
_newRevisionGroupBox.Size = new System.Drawing.Size(this.Width, 400);
Button ApplyButton = new Button();
ApplyButton.Text = "Apply";
ApplyButton.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
ApplyButton.DialogResult = DialogResult.OK;
_newRevisionGroupBox.Controls.Add(ApplyButton);
this.Controls.Add(_newRevisionGroupBox);
But the second GroupBox will not show up. It's supposed to show up in the grey area in the image above but that area remains grey.
I tried various things. For example, the first GroupBox's dock style is set to fill by default. When I add the second group box, I set the first groupbox to top and the second group box to bottom. I'm also giving the second groupbox a size as you can see. I'm also calling refresh on the UserControl.
Your help is very much appreciated.
I have a form with a UserControl inside it, and inside that UserControl is a GroupBox:
Under certain conditions, I want to add another GroupBox below the first one. When those conditions are met, I add it dynamically as the following code snippet from the UserControl shows:
RevisionGroupBox.Dock = DockStyle.Top;
_newRevisionGroupBox = new GroupBox();
_newRevisionGroupBox.Text = "New Project Revision";
_newRevisionGroupBox.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
_newRevisionGroupBox.Dock = DockStyle.Bottom;
_newRevisionGroupBox.Size = new System.Drawing.Size(this.Width, 400);
Button ApplyButton = new Button();
ApplyButton.Text = "Apply";
ApplyButton.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
ApplyButton.DialogResult = DialogResult.OK;
_newRevisionGroupBox.Controls.Add(ApplyButton);
this.Controls.Add(_newRevisionGroupBox);
But the second GroupBox will not show up. It's supposed to show up in the grey area in the image above but that area remains grey.
I tried various things. For example, the first GroupBox's dock style is set to fill by default. When I add the second group box, I set the first groupbox to top and the second group box to bottom. I'm also giving the second groupbox a size as you can see. I'm also calling refresh on the UserControl.
Your help is very much appreciated.