Windows Forms and Panels

0

How do I use a single form to display several screens, such as login, registration, administration, etc.?

It is possible to use the panel component, but the rendering of the panel is slow, as well as being unpleasant to develop in this way.

I may be talking shit, but I imagine a solution like that.

frmPrincipal = Contains Windows Form with the fixed components.

duvLogin = Contains the visual components that will be activated in frmPrincipal when requested.

duvRegistro = Contains the visual components that will be activated in frmPrincipal when requested.

I would like to know the correct or best way to organize the screens in the form.

    
asked by anonymous 29.10.2015 / 10:31

2 answers

1

The best thing to do is to use the IsMdiContainer property of the main form. Set it to true .

In other (internal) forms, you use the property MdiParent (defined in code before show() ).

So you only have one main screen and other internal screens. I'll post a detailed tutorial link for more information:

link

For the specific case of login screen, I recommend using another form, hiding the first, opening and displaying the second and closing the first (in that order). For others use the case quoted above.

    
29.10.2015 / 11:12
0

You can use UserControl to build the login, registry, and etc components, and add the corresponding control to the main form.

Creates a% login_context and another record, and in the main form you add a panel to load UC :

For the code below, imagine the following situation:

Parent Form :

  • UCs ;
  • Users Control ;

  • UC login;

  • UC Registry;

  • private UC_login uc_login=new UC_login ();
    private UC_Registro uc_registro=new UC_Registro ();
    
    public void TrocarUC(string controle)
    {
       panel_principal.Controls.Clear();
       if(controle=="login")
       {
          panel_principal.Controls.Add(uc_login);
       }
       else if(controle=="registro")
       {
           panel_principal.Controls.Add(uc_registro);
       }
    }
    
        
    14.04.2016 / 23:22