I have problem in adding button in panel,
I already read how to use delegate
and I write it in my code,
But after that only this exception is suppressed But no Button Added to my Panel.
Here is My Code
public delegate void AddControlToPanelDlgt(Panel panel, Control ctrl);
private void AddControlToPanel(Panel panel, Control ctrl)
{
if (panel.InvokeRequired)
{
panel.Invoke(new AddControlToPanelDlgt(AddControlToPanel), panel, ctrl);
return;
}
if (ctrl.InvokeRequired)
{
ctrl.Invoke(new AddControlToPanelDlgt(AddControlToPanel), panel, ctrl);
return;
}
panel.Controls.Add(ctrl); //<-- here is where the exception is raised
}