I have several usercontrols that I add and remove from my application's main form as the user makes different selections. The problem I'm having is that when I try and add a particular user control to the form the application stalls. I add the same user control at another time in the application and that works fine, but some reason in this instance it won't let the user control be added.
Here is a bit of the code
br]
public Hall loadHall( string[] pM )
{
cnt_Hall= new Namespace.Hall();
cnt_Hall.Location = new Point(0,0);
cnt_Hall.Name = "cnt_Hall";
cnt_Hall.Size = new Size( 800, 600 );
cnt_Hall.TabIndex = 0;
cnt_Hall.init( this, Comm, pM );
MethodInvoker mInvoke = null;
mInvoke += new MethodInvoker( addHallRemoveCano );
this.Invoke(mInvoke);
return cnt_Hall;
}
private void addHallRemoveCano()
{
this.Controls.Remove(this.cnt_Cano);
cnt_Cano.Dispose();
cnt_Cano = null;
this.Controls.Add(this.cnt_Hall); // stops right here
}
Here is a similiar bit of code which works
br]
public void loadCreation()
{
Comm.ServerSend( "At Creation" );
cnt_Hall = new Namespace.Hall();
cnt_Hall.Location = new Point(0,0);
cnt_Hall.Name = "cnt_Hall";
cnt_Hall.Size = new Size( 800, 600 );
cnt_Hall.TabIndex = 0;
cnt_Hall.init( this, Comm, cnt_Sel.GetShowing );
Comm.getMySel = null;
Comm.getMyHall = cnt_Hall;
MethodInvoker mInvoke = null;
mInvoke += new MethodInvoker( addCreationRemoveSelect );
this.Invoke(mInvoke);
}
private void addCreationRemoveSelect()
{
this.Controls.Add(cnt_Hall);
this.Controls.Remove(this.cnt_Sel);
cnt_Select.Dispose();
cnt_Select = null;
}