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.

Recommended Answers

All 2 Replies

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.