I have a login form(Form1). Which has two text box(textBox1,textBox).
when i clicked the Login Button another new form(Form2) is opened.This new form is
a MDIPARENT form. I want to set the text of a lable of a new child form of this parent
form which is same as the text of TextBox1 of Form1. Please Help me in C# code.

8 Years
Discussion Span
Last Post by Geekitygeek

Hello Bijaya123,
this is my variant:
You have to add to your form2 two public properties (for example Field1 and Field2).

public string Field1{get;set;}
public string Field2{get;set;}

When you open Form2 you have to add values to properties:

Form2 frm = new Form2{Field1 = TextBox1.Text, Field2=TextBox2.Text};

After it you can use Field1 and Field2 for setting Labels or another controls.

Hope it help you


Another way to do it is to pass a reference to the First form into the Second so that the second form can access public memebers of the first.
My tutorial outlines how to acheive this.

This topic has been dead for over six months. 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.