我有 2 个按钮,单击这些按钮时会读取不同的文件。由于文件很大,我使用 来显示 readfile MsgBox
,所以我想将它显示在richTextBox
.
当我单击这些按钮中的任何一个时,如何打开richTextBox
并显示?read file
private void button1_Click(object sender, EventArgs e)
{
DisplayFile(FileSelected);//DisplayFile is the path of the file
var ReadFile = XDocument.Load(FileSelected); //Read the selected file to display
MessageBox.Show("The Selected" + " " + FileSelected + " " + "File Contains :" + "\n " + "\n " + ReadFile);
button1.Enabled = false;
}
private void button2_Click(object sender, EventArgs e)
{
FileInfo file = (FileInfo)comboBox2.SelectedItem;
StreamReader FileRead = new StreamReader(file.FullName);
string FileBuffer = FileRead.ReadToEnd(); //Read the selected file to display
//MessageBox.Show("The Selected" + " " + file + " " +"File Contains :" + "\n " + "\n " + FileBuffer);
// richTextBox1.AppendText("The Selected" + " " + file + " " + "File Contains :" + "\n " + "\n " + FileBuffer);
//richTextBox1.Text = FileBuffer;
}
还有其他方法吗?