我有2個按鈕,當我點擊這些按鈕時我讀取了不同的文件。由於文件很大,所以我使用MsgBox
來顯示讀取文件,所以我想在richTextBox
中顯示它。按鈕點擊打開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;
}
有沒有其他方法可以做到這一點?
所以,你要顯示一個消息框一個RichTextBox,對不對? –
創建新的窗體,並把它只有RichTextBox,也許關閉按鈕,然後顯示它在按鈕單擊 –
@ Krishanu Dey:是的,如果它是一個大文件,那麼我想滾動... – linguini