Need help finding a TableLayoutPanel added at run time to a tab control of a winform. Please find example code below. Any help would be appreciated.
private void GenerateControls()
{
TableLayoutPanel tp = new TableLayoutPanel();
tp.Name = "tpName";
tab1.Controls.Add(tp);
}
private void findTablePanelControl()
{
TableLayoutPanel tp = (TableLayoutPanel)this.Controls.Find("tpName", true)[0];
string name = tp.Name;
}
I receive the follow error message: Index was outside the bounds of the array.
I also tried the following code, but get this error (Object reference not set to an instance of an object) on the "string name =" line:
TableLayoutPanel tpParseSchema = (TableLayoutPanel)this.Controls.Find("tpParseSchema", true).FirstOrDefault();