Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 923051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:07:55+00:00 2026-05-15T19:07:55+00:00

I am dropping a text snippet (from IE) from a web page, that might

  • 0

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;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:07:55+00:00Added an answer on May 15, 2026 at 7:07 pm

    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) {

        bool result = false;
    
        if (e.Data.GetDataPresent(DataFormats.Text))
        {
            System.Windows.Forms.IDataObject data = e.Data;
            if (data.GetDataPresent("HTML Format"))
            {
    
            byte[] rawHtmlBytes = HtmlFromIDataObject.GetHtml(data);
            string _html = Encoding.UTF8.GetString(rawHtmlBytes);
    
            object vk_missing = System.Reflection.Missing.Value;
            //1.Save the html file (in %temp% folder) 
            string    file = IOUtil.CreateTextFile(_html, ".html");
    
            object oFile = file;
            Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
    
            //2.open the html file
            Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(ref oFile, ref
                    vk_missing, ref vk_missing, ref vk_missing, ref vk_missing, ref vk_missing,
                    ref vk_missing, ref vk_missing, ref vk_missing, ref vk_missing, ref  vk_missing,
                    ref vk_missing, ref vk_missing, ref vk_missing, ref vk_missing, ref vk_missing);
    
            //3.saving as rtf
            string directory = Path.GetDirectoryName(file);
            string fileName = Path.GetFileNameWithoutExtension(file);
            file = Path.Combine(directory, fileName+ "_" + ".rtf");
    
            object oSave = file;
            doc.SaveAs(ref oSave, ref vk_missing, ref vk_missing, ref vk_missing, ref vk_missing, ref vk_missing, ref vk_missing, ref vk_missing, ref vk_missing, ref vk_missing, ref vk_missing, ref vk_missing, ref vk_missing, ref vk_missing, ref vk_missing, ref vk_missing);
    
            result = true;
            }
        }
    
        return result;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're supporting legacy code that is dropping a cookie and setting the expiration to
Does anyone have any idea when Microsoft might be dropping another Silverlight 4 public
I am trying to get date from Jquery ui date-picker by dropping some events
I'm wanting to put a text on the web with paragraph numbers and sidenotes.
I have this example code: string query = select * from xy where id
I'm trying to read from a text file in Netbeans. In the top level
I'm using Hibernate for a Java-based Web Application and want to add full-text search
Drag is not working after dropping on the area. I have used Jquery UI
is it possible to change the left position of a div after dropping it?
how can i turn my listbox to resort able by dragging and dropping in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.