OK, on your main-form, you'll have a panel
private Panel _myPanel
Design your user-controls (eg. UserControl1), to add to the main on the
main-form, code (not design) the following in your button handler:
// Instantiate the user control to display in the panel.
UserControl1 uc = new UserControl1();
// Set the user-control's dock-style to Fill .
uc.Dock = DockStyle.Fill;
// Add the control to your place-holder panel.
_myPanel.Controls.Add( uc );
Obviously, you'll need to add logic to check to see whether you'd
already created the control. You could record record the variable in
your form, or just iterate through the controls and look for it. The
above might become:
// Within the button handler . . .
// Search the panel for a user-control of the desired type.
// If a user-control of the right type was found, bump it to
// the top of the Z-order.
foreach( Control c in _myPanel.Controls )
{
if ( c is UserControl1 )
{
c.BringToFront();
return;
}
}
// OK, the control of that type wasn't found, go create one.
// IMPLEMENT THE CODE AT THE TOP.
There are a number of ways to do this, this just gives you an idea of
what to do.
Sean
> Thanks for your quick repley!
>
[quoted text clipped - 75 lines]
>>
>>Sean
Sean J Donovan - 15 Sep 2004 17:19 GMT
I guess the other option is to use the TabControl, which sounds kinda'
close to what you're trying to do.
> OK, on your main-form, you'll have a panel
>
[quoted text clipped - 122 lines]
>>>
>>> Sean
Tinus - 15 Sep 2004 17:35 GMT
Thanks a lot!
Tinues
> I guess the other option is to use the TabControl, which sounds kinda'
> close to what you're trying to do.
[quoted text clipped - 125 lines]
> >>>
> >>> Sean