I've got a really weird problem and i'm wondering if it's a visual's bug or if i'm doing something wrong. Here's a simple code of an overriden Panel class:
public class MyPanel : Panel
{
private TableLayoutPanel table = new TableLayoutPanel();
public MyPanel()
{
this.Controls.Add(table);
table.BackColor = Color.Green;
}
public override System.Drawing.Color BackColor
{
get
{
return table.BackColor;
}
set
{
table.BackColor = value;
}
}
}
If i put the control on a form and build the project, visual will generate an error and opening the project again will be impossible. However if i change TableLayoutPanel to TextBox, it works fine. Also, if i set the BackColor in the constructor before adding the control to the Controls collection, it also works fine. What is the problem? or is it just a bug?