Hello,
I want to add a Panel to a UserControl but it's not showing up.
Here's my code:
Adding the UserControl (to another UserControl -- i.e. QuickStartControl):
Adding the panel to the MasterFlowLayoutPanel UserControl:
The panel won't show up. Any idea why?
I want to add a Panel to a UserControl but it's not showing up.
Here's my code:
Adding the UserControl (to another UserControl -- i.e. QuickStartControl):
Code:
public partial class QuickStartControl : UserControl
{
public QuickStartControl()
{
InitializeComponent();
this.Load += new EventHandler(QuickStartControl_Load);
}
private void QuickStartControl_Load(object sender, EventArgs e)
{
MasterFlowLayoutPanel masterFlow = new MasterFlowLayoutPanel();
masterFlow.Dock = DockStyle.Top;
masterFlow.BackColor = Color.Black;
this.Controls.Add(masterFlow);
}
}
Adding the panel to the MasterFlowLayoutPanel UserControl:
Code:
public partial class MasterFlowLayoutPanel : UserControl
{
public MasterFlowLayoutPanel()
{
InitializeComponent();
this.Load += new EventHandler(MasterFlowLayoutPanel_Load);
}
private void MasterFlowLayoutPanel_Load(object sender, EventArgs e)
{
AddInitialSafeguardFlowLayoutPanel();
}
public void AddInitialSafeguardFlowLayoutPanel()
{
Panel p = new Panel();
p.Location = new Point(0, 0);
p.Size = new Size(100, 100);
p.Dock = DockStyle.Fill;
p.Anchor = AnchorStyles.Left | AnchorStyles.Right;
p.BackColor = Color.Red;
this.Controls.Add(p);
}
}
The panel won't show up. Any idea why?