I have an MDI form "mdi1".
And another form "form1"
On mdi1 I have a label "lbl1"
I want to change text of lbl1 when a button on form1 is clicked.
form1 is a child form of mdi1.
How can i do this.

6 Years
Discussion Span
Last Post by Geekitygeek

This reference might help. :twisted: Looks like it addresses exactly what you're asking for here with about 2 lines of code.

Hope this helps :) Please remember to mark this thread solved once your issue is resolved.

Form f = this.MdiParent;
            f.Controls["label1"].Text = "Hello MARKAND911";

This will solve your problem.Place the code inside the button Click event


Is it not bad OO design to directly access the parent controls from the child? Wouldnt using a property be a more appropriate method?
It maintains encapsulation and allows you to validate the value passed from the child:

public partial class Parent : Form
    //write-only property
    //could add get method to allow child to read from parent control
    public string TextBox1Value
            //check input is valid
            if (value == "Valid")
                //write value to control
                TextBox1.Text = value;

public partial class Child : Form
    private void WriteToParent (string Text)
        //retrieve parent and cast to parent type then send text to property
        ((Parent)this.MdiParent).TextBox1Value = "Valid";
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.