日期:2014-05-19  浏览次数:20977 次

怎么打开一个TXT文本显示到richTextBox里
用   一个按钮打开本地一个文本   显示到richTextBox
小弟很菜哪位大虾给解绝一下

------解决方案--------------------
private void button1_Click(object sender, EventArgs e)
{
if (DialogResult.OK == openFileDialog1.ShowDialog())
{
richTextBox1.Text = File.ReadAllText(openFileDialog1.FileName);
}
}
------解决方案--------------------
or try

private void button2_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
richTextBox2.LoadFile(openFileDialog1.FileName, RichTextBoxStreamType.PlainText);
}
}