in visual studio 2010 c#
i need to open a file in the Parent window then show the file contents in the child window.
i have the open file dialog and the display of the child window working.. i just cant get display the file contents into the child window.
I am doing this in the openToolStripMenuItem_Click_1 function.
Any suggestions would greatly appreciated.
private void openToolStripMenuItem_Click_1(object sender, EventArgs e)
{
OpenFileDialog ofdOpenFile = new OpenFileDialog();
ofdOpenFile.Title = "Select a File To Open";
ofdOpenFile.FileName = "";
ofdOpenFile.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
if (ofdOpenFile.ShowDialog() == DialogResult.OK)
{
RichTextBox rtb = GetRichTextBox();
if (rtb == null)
{
FormChild fc = new FormChild();
fc.MdiParent = this;
fc.Show();
string str = "this is the title bar text";
fc.Text = str;
}
if (rtb != null)
{
rtb.LoadFile(ofdOpenFile.FileName, RichTextBoxStreamType.RichText);
}
}
}