How to use control of form1 again from form2 in window application

Posted by Oswaldlily under ASP.NET on 1/24/2012 | Points: 10 | Views : 1144 | Status : [Member] | Replies : 1
Form2.cs

private void button1_Click(object sender, EventArgs e)
{
FindMapper fm = new FindMapper();
string uname=textBox1.Text;
int a = fm.Findfunction(uname);
if (a == 0)
{
MessageBox.Show("Success");


}
else if(a==1)
{
MessageBox.Show("Failure");
}
}


if its success if(a==0) in case
I need to redirect to form1 and uname should be copied to Tabcontrol of form1

*In form1,I has Tabcontrol which has 2 Tabpages-Contacts and Conversation

In tabpages.selectedtab ( Contacts) ,I need to display uname of form2




Responses

Posted by: Jawed_akhtar786 on: 1/24/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

Try this

private void button1_Click(object sender, EventArgs e)
{
string str = "Test";
if (textBox1.Text == str)
{
MessageBox.Show("Success");

Form1 frm1 = new Form1();
label2.Text = str;
Label lbl = new Label();
lbl =(Label) frm1.Controls["label1"]; //label1 is a Lable control on form1
lbl.Text = str;
frm1.Show();
this.Hide();
}
else
{
MessageBox.Show("Failure");
}
}


Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response