is there any way that i can import documents to richtextbox any way is good......
thanx
Sevki
-
-
Metal MilitiA wrote:
is there any way that i can import documents to richtextbox any way is good......
thanx
Sevki
What kind of documents? Word documents? Rich text documents? HTML documents? Excel documents? OpenOffice documents? Be more specific. -
any as in any of those above there is no spesifications any would do..... thanks
-
I don't know if this is the right answer. But in VB you can do a method called LoadFile(filename), if that is any help.
-
public void LoadFile(String path, RichTextBox richTextBox)
{if (!File.Exists(path)) throw new FileNotFoundException("the specified file doesn't exist.");String fileExtension = System.IO.Path.GetExtension(path).ToUpper();
MessageBox.Show(fileExtension.ToString());
String dataFormat = DataFormats.Text;
if (fileExtension == "TXT")
{dataFormat = DataFormats.Text;
}
else if (fileExtension == "XAML")
{dataFormat = DataFormats.Xaml;
}
else if (fileExtension == "RTF")
{dataFormat = DataFormats.Rtf;
}
using (FileStream fileStream = File.OpenRead(path))
{TextRange textRange = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);
if (textRange.CanLoad(dataFormat))
{textRange.Load(fileStream, dataFormat);
}
}
}
Currently WPF's RichTextBox only supports reading txt, xaml, rtf or xaml package.
Sheva -
XHTML and HTML should be added in short order. Add it to your list WPF team.
Waggles finger. -
nks guys you've been great help
-
odujosh said:
XHTML and HTML should be added in short order. Add it to your list WPF team.
Waggles finger.I definately agree.
WPF team should add easy-loading support to the following basic docs:
txt
rtf
xml ([x]html) etc.
doc(x)
pdf (??)
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.