0

I remember MSN Messenger used to display a login. And upon logging in, it displayed a loading animation. On success it displayed all your contacts. All that in one single form.

How is that done?

I dont only know how to make new forms, or display forms inside forms. But that is not how its done, right?


I am opened to suggestions on how to improve my question. I know I barely could explain myself. Perhaps with your help, i can edit my question to be more helpful to others

Karandawov
  • 93
  • 1
  • 8
  • It is likely that they aren't forms within forms but rather controls within forms, particularly container controls. For example, you can make custom control classes within the designer that will hold several other controls and basically behave like a form. As far as forms within forms go, you can look into [multiple document interface (MDI)](https://msdn.microsoft.com/en-us/library/xyhh2e7e(v=vs.110).aspx) – j.i.h. Sep 24 '15 at 15:07
  • You might be looking for [this](https://msdn.microsoft.com/en-us/library/aa984329(v=vs.71).aspx) – Rahul Jha Sep 24 '15 at 15:08
  • @J.i.h, i think you are totally right... – Karandawov Sep 24 '15 at 15:13

1 Answers1

0

you can user the UserControl object. You can dock them to a panel in the main form.

This example uses a Panel object in the main form for docking (named pnlCentre).

public partial class MainForm : Form
{
    DummyControl1 dummy1;
    DummyControl2 dummy2;

    public MainForm()
    {
        InitializeComponent();


        dummy1 = new DummyControl1();
        dummy2 = new DummyControl2();

        pnlCentre.Controls.Add(dummy1);
        pnlCentre.Dock = DockStyle.Fill;
    }
    // switches between screens
    public void switchscreen()
    {
        pnlCentre.Controls.Remove(dummy1);
        pnlCentre.Controls.Add(dummy2);
        pnlCentre.Dock = DockStyle.Fill;

    }

}

public partial class DummyControl1 : UserControl
{
    // can be filled from the designer
}

public partial class DummyControl2 : UserControl
{
    // can be filled from the designer
}
martijn
  • 1,417
  • 1
  • 16
  • 26
  • sorry for not accepting your answer in such a long time. I am new to c#, that i understood your answer only today. it is EXACTLY what i needed! – Karandawov Sep 27 '15 at 12:44
  • If you would be so nice to tell me how can i fill DummyControl1 from the designer? – Karandawov Sep 27 '15 at 12:46
  • nevermind. here is the link that explains it all. Anyone in need - enjoy: https://msdn.microsoft.com/en-us/library/114xc3e5(v=vs.90).aspx – Karandawov Sep 27 '15 at 14:47
  • I forgot i had answered this... I'm glad you figured out the rest on your own. If I need to clarify anything else let me know – martijn Sep 30 '15 at 04:47