B Rawlings

B Rawlings

  • NA
  • 6
  • 3.5k

Adding contents of text file to child form

May 20 2014 4:41 PM

 I am trying to add the contents of a text file to a text box in a child form using 'Open' from the parent file. This is what I have so far:

 
private void openToolStripMenuItem_Click(object sender, EventArgs e)

{

openFileDialog1.InitialDirectory = Directory.GetCurrentDirectory();

// Display the file open dialog box and show only text files.

DialogResult responseDialogResult;

openFileDialog1.Filter = "Text Files (*.txt)|*.txt";

responseDialogResult = openFileDialog1.ShowDialog();

// Check that the user did not click the cancel button.

if (responseDialogResult != DialogResult.Cancel)

{

// Open the child form.

Form2 childOneForm = new Form2();

childOneForm.MdiParent = this;

childOneCountInteger++;

childOneForm.Text = openFileDialog1.FileName;

childOneForm.Show();


 


Answers (4)