Access controls on an MDIcontainer form from your child forms

0

I am working on an MDIcontainer form with a panel that I will use as a status bar at the bottom to show labels and a progressbar with information about some process that is done within the child forms, the problem I have is that I can not show or hide a label that is in that status bar of the MDIcontainer form Is there any way to access the MDIcontainer Form controls from your children ?, thanks in advance.

    
asked by Julio Rios Garcia 02.10.2018 в 23:17
source

1 answer

0

In your form that works as MDI container declares the controls that you want to expose as public, here is the example of the ToolStripStatusLabel control

    public ToolStripStatusLabel ToolStripStatusLabel
    {
        get { return tsslNombreUsuario; }
    }

Now in the form that is going to be the child (MDI Child) you access the MdiParent property to extract the parent and since you already have the ToolStripStatusLabel control as public, you can access it:

            FormMdiParent mdiParent = (FormMdiParent)this.MdiParent; //FormMdiParent es el tipo de clase de tu formulario MDIParent
            mdiParent.ToolStripStatusLabel.Text = "Asignando valor a ToolStrip en Mdi Parent desde Mdi child";

I hope it will be useful for you. Greetings.

    
answered by 03.10.2018 / 01:39
source