WPF的RichTextBox如何赋值给它

xiaogua 2010-01-27 05:58:20
WPF的RichTextBox如何赋值给它?
我都没找到Text属性
...全文
608 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
EagleZhangJB 2012-05-10
  • 打赏
  • 举报
回复
/// <summary>
/// 打开文件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Image_MouseLeftButtonUp_1(object sender, MouseButtonEventArgs e)
{
OpenFileDialog openfile = new OpenFileDialog();
openfile.Filter = "Rtf文件(*.Rtf)|*.Rtf|txt文件(*.txt)|*.txt|所有文件(*.*)|*.*";
string fileName = "";
if (openfile.ShowDialog().Value)
{
fileName = openfile.FileName;
string fileExtension = System.IO.Path.GetExtension(fileName).ToUpper();
if (fileExtension == ".TXT")
{
using (FileStream fileStream = File.OpenRead(fileName))
{
TextRange textRange = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);
if (textRange.CanLoad(DataFormats.Text))
{
textRange.Load(fileStream, DataFormats.Text);
}
}
}
}
}
RexZheng 2010-01-27
  • 打赏
  • 举报
回复
.Document
ashoulo 2010-01-27
  • 打赏
  • 举报
回复
顶 下
xiaogug01 2010-01-27
  • 打赏
  • 举报
回复
RichTextBox是高级版的TextBox,能包含格式化的文字,内容存在Document(FlowDocument类型)属性(不是Text属性)里
波导终结者 2010-01-27
  • 打赏
  • 举报
回复
http://www.cnblogs.com/RMay/archive/2008/07/22/1248905.html

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧