I have a multiform project and I am trying to send data from the parent form to the child form. I created a property in the parent form as follows:
public string conference;
public string Conference
{
get
{
return conference;
}
}
In the child form I try to access it as follows:
conference = Form1.Conference;
I get a compile error stating that an object reference is required to access the non static property.
Any helpful ideas would be appreciated.
Thanks
Satish KathiPosted Jul 25, 2008, 3:06 PM
I have answered similar question
http://www.c-sharpcorner.com/Forums/ShowMessages.aspx?ThreadID=44730
Here is the code
public partial class Form11 : Form
{
private string conference; public string Conference{
get{
return conference;}
}
public Form11(){
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form12 f = new Form12(this);
f.ShowDialog();
f.Dispose();
}
}
Form2.....
public partial class Form12 : Form
{
private Form11 _parent;
public Form12(Form11 form)
{
InitializeComponent();
_parent = form;
}
private void button1_Click(object sender, EventArgs e)
{
string halo = _parent.Conference;
MessageBox.Show(halo);
}
}