0
That code should work as long as the accessibility of textBox1 has been changed from private to either internal or public.
To deal with the ListBox, you'd need this code:
if (p1.listBox1.SelectedIndex > -1)
{
label2.Text = p1.listBox1.SelectedItem.ToString();
}
else
{
label2.Text = "";
}
Accepted 0
Hello Friend,
As per my suggestion what you can do is in your form2 create a constructor which accepts two arguements. So your code for form2 will be somewhat like the following
public class Form2:Form
{
private string _val1,_val2;
public Form2()
{
//Default Constructor
}
public Form2(string value1,string value2)
{
//Set the value of value1 and value2 to the class level variables of your form2
}
}
And finally when you are creating the instance of form2 in your form1 class try to call your this constructor, like the following.
Form2 objForm2=new Form2(txtTextBox1.Text,ListBox1.SelectedItem.Text);
Hope that solves your problem.
With Regards,
Vishal Gilbile.