How about the load event of the Form
?
private void form_load(object sender, Eventargs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.FileName = "Changes.txt";
string strfilename = openFileDialog1.FileName;
string filetext = File.ReadAllText(strfilename);
richTextBox1.Text = filetext;
}
I'm not sure what you want to do in the richTextBox1_TextChanged
event, maybe you could provide more information regarding this.
Having seen your edit, your'e still better off using the button to open the dialog and selecting a file that way. More intuitive then selecting the RichTextBox
to trigger the OpenFileDialog
.