Error Creating Window Handle

Nov 8 2005 1:47 AM


Hi,

I'm my project i'm getting "Error Creating Window Handle" message on continuous button Click. I haven't used MDI forms. Instead i'm displaying Panel( Includes all controls

similar to displaying a form )for each and every button Click.

I'm not able to dispose a panel cos i'm calling one panel from another.

Like this,

In my Main Form, i'm having a default panel (pnlMain) and 15 to 20 buttons
In each button click, i'm displaying the respective panels in place of default panel in Main Form.
Like this,
private void btnFirst_Click(object sender, System.EventArgs e)
{
FrmFirst ObjFirstForm = new FrmFirst();
try
{
pnlMain.Controls.Clear();
pnlMain.Controls.Add( ObjFirstForm.DisplayPanel );
}
catch( Exception ex )
{

}
}

FrmFirst:
-------------
public Panel DisplayPanel
{
get
{
return this.pnlFirst;
}
}

On continuous click of btnFirst, i'm getting "Error Creating Window Handle" exception and my Application goes off but it is there in Task Manager

Thanks,

Vidhya