jeudi 9 février 2017

Parental form give NullReferenceException

Vote count: 0

When I try to change the label in the parent form it gives me a NullReferenceException.

Form1

    public string LabelText
    {
        get
        {
            return label1.Text;
        }
        set
        {
            label1.Text = value;
        }
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        Form2 f2 = new Form2();
        f2.ShowDialog();
    }

Form2

    private void button1_Click(object sender, EventArgs e)
    {
        ((Form1)ParentForm).LabelText = textBox1.Text;
        this.Close();
    }

asked 38 secs ago

Let's block ads! (Why?)



Parental form give NullReferenceException

Aucun commentaire:

Enregistrer un commentaire