passing data child parent parent child

  • Thread starter Thread starter Maarten
  • Start date Start date
M

Maarten

hi,
how can i pass data from a parrentform to a childform and reverse
or retreave data from a childform of the parentform and reverse.

Regards Maarten
 
A form is generated from a class. So simply add public or internal
properties to the child form class to pass data to it from the parent form.

Simply instantiate the child form class, set the properties, and then show
the form.

Pete
 
Dearest Maarten,
how can i pass data from a parrentform to a childform and reverse
or retreave data from a childform of the parentform and reverse.

Passing down variables to child forms or retrieving data from them is
very easy. While you're creating a new form, you're allowed to set a
different constructor - i.e. you can specify your own variables in the
form's constructor. This should allow you to pass down variables to
your child form while you're creating it.

To retrieve data from a parent form, simply declare a public variable
in the Parent form, and access it from the child form.

Heh, simple.
 
Thank's for the answers, they where not what i expected, but helped me much
more
than i expected.
i'm beginning to have a clear view on object orientated programmaing.

now i'm facing an other problem.
here is my code:

on a parrentform:

using UCAnalog;

namespace frmsettings
{
public class settings : System.Windows.Forms.Form
{
private void button2_Click(object sender, System.EventArgs e)

{

Analog an = new Analog();

an.listsetup();

this.Close();

}

}

}

on a usecontrol ;
namespace UCAnalog

{

public class Analog: System.Windows.Forms.UserControl

{

public void listsetup()

{

MessageBox.Show(test");

lstout.Items.Add ("Channel ",false);

}

}

}

I know the function listsetup in the class analog is called because the
messagebox gets activated.
but the item won't add in the checkedlistbox.

hope someone can help me.

greets Maarten.
 
Back
Top