views:

18

answers:

1

I initially show a MDI form to a user which includes a file menu . If i select new from it i will get a child form there i will have some text boxes there i will fill some data and click on save at that point i would like to load a tree view on the MDI form showing the file with the data i saved i am not going to save that file any where in my PC or some where else. So how can i achieve this..

For more information download the tool from

         http://www.achtools.com/downloadTrial.aspx

and run this in your PC i would like to implement such a behaviour...

A: 

Got the answer

   public partial class Form1 : Form
 {
  public Form1()
  {
  InitializeComponent();
}

private void buttonOpenForm2_Click(object sender, EventArgs e)
{
  Form2 form2 = new Form2(this);
  form2.Show(this);
}

public void LoadingDataFromForm2(string[] myArray)
{
  label1.Text = myArray[0]; //1st value from textBox1 in form2
  label2.Text = myArray[1]; //2nd value form textBox2 in form2
}
 }

public partial class Form2 : Form
 {    
   Form1 form1 = new Form1();

   public Form2(Form1 _form1)
  {
  InitializeComponent();
  form1 = _form1;
}

private void buttonSave_Click(object sender, EventArgs e)
{
  string value1 = textBox1.Text.Trim();
  string value2 = textBox2.Text.Trim();

  string[] arrayValues = new string[] { value1, value2 };
  form1.LoadingDataFromForm2(arrayValues);
  //IF YOU WANT TO CLOSE THE FORM2 AFTER PRESSING SAVE BUTTON:
  this.Dispose();
}
}
Dorababu