I have a Code in which there are three rows added in designview. When user click on this button i am getting its click event and creating two panels with white and blue color resp. inside first row. |
private void button1_Click(object sender, EventArgs e)
{
this.tableLayoutPanel1.AutoSize = true;
tableLayoutPanel1.ColumnCount = 2;
tableLayoutPanel1.RowStyles.Insert(1, new RowStyle(SizeType.Percent,100));
tableLayoutPanel1.ColumnStyles.Insert(1, new ColumnStyle(SizeType.Percent, 100));
this.panel1.AutoSize = true;
Panel newPanel = new Panel();
newPanel.BackColor = Color.White;
newPanel.Dock = DockStyle.Fill;
newPanel.AutoSize = true;
tableLayoutPanel1.Controls.Add(newPanel, 0, 1);
Panel newPanel2 = new Panel();
newPanel2.BackColor = Color.Blue;
newPanel2.Dock = DockStyle.Fill;
tableLayoutPanel1.Controls.Add(newPanel2, 1, 0);
tableLayoutPanel1.SetColumnSpan(this.button2, 2);
tableLayoutPanel1.SetColumnSpan(this.button3, 2);
}NEED:
Now i am not able to create next panel in the remaining portion of that row with suppose of black color.
One more thing if there is another button outside of this tablelayoutpanel , then how can i turn back to the previous one after this button click's as that was before creating dynamic panels? I mean first row should contain only one panel that was of maroon color with dock fill.
Answers
Know the answer? Post it. Somebody with the same question will find it here.