I am dropping a text snippet (from IE) from a web page, that might contain links too.
string _rtf = (string) data.GetData(“Rich Text Format”);
RichTextBox box = new RichTextBox();
box.DetectUrls = true;
box.SelectedRtf =_rtf;
box.SelectAll();
_rtf = box.SelectedRtf;
The problem is, when i save the content of the rich text box, the links will not remain, they are changed to normal text. How can i keep the links to remain functional and save the text to an RTF or DOC file?
I am using HandleDropEvent function for handling the dragdrop that looks like this:
protected override bool HandleDropEvent(DragEventArgs e)
{
bool result = false;
if (e.Data.GetDataPresent(DataFormats.Text))
{
System.Windows.Forms.IDataObject data = e.Data;
if (data.GetDataPresent("Rich Text Format"))
{
string _rtf = (string) data.GetData("Rich Text Format");
RichTextBox box = new RichTextBox();
box.DetectUrls = true;
box.Text = _rtf;
box.SelectedRtf =_rtf;
box.SelectAll();
_rtf = box.SelectedRtf;
box.SaveFile("filename.rtf", RichTextBoxStreamType.RichText);
result = true;
}
}
return result;
}
Solved it!! First i saved it as a html page then opened it by word programatically and saved as an rtf file.
The Word component made the whole conversion.
protected override bool HandleDropEvent(DragEventArgs e) {