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 6016637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:00:41+00:00 2026-05-23T03:00:41+00:00

Right now I want to prevent the user from pasting into a rich text

  • 0

Right now I want to prevent the user from pasting into a rich text box any content with an image of any type. Clipboard.ContainsImage won’t work as it only detects some types and it won’t be detected if the clipboard contains text with the image.

What I need is a way to detect an image inside a text, an image alone, multiple images… inside the clipboard to be able to clear the clipboard if this happens. I need to avoid this heavy content to reach the database…

Thanks

  • 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-23T03:00:42+00:00Added an answer on May 23, 2026 at 3:00 am

    The problem is greater than simply preventing an image, since RTF can embed any object including word documents or arbitrary binary data.

    The only 3 options I can think of

    1. Limit the maximum data size you allow saving to the database, at which point images under that size arn’t a problem since its with in the allowable size.

    2. Use library that will let you parse and understand the RTF content so you can check it for anything other than standard text and formatting. Then you can strip out any embedded binary objects. Alternatively, you could handle WM_PASTE and check the clipboard for RTF text. If it has RTF text you can parse this and strip embedded objects when pasting rather than when saving. If it doesn’t have an RTF version, don’t forget to check if it has a plain text version instead.

    3. Intercept and handle the WM_PASTE message and use RichTextBox.Paste(DateFormats) to control which data types can be pasted. You can then limit this to only pasting the plain text version of the data on the clipboard, which cannot contain embedded objects. The disadvantage here is the user can’t paste formatted text from a different application, all formatting will be lost.

    1 is the simplest, but accepts that users will be able to embed small images and other small objects such as word documents or videos, so long as it is under the maximum size.

    2 is more complex but offers the best user experience.

    3 is simpler than 2, but offers a poor user experience, as if you didn’t care about formatted text you wouldn’t be using a rich text box. Unless you only want plain text and are using for its larger text capacity, but if this were the case you’d only be fetching the plain text version to save to the DB, which wouldn’t contain images.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an AutoCompleteTextView set up right now, but I want to prevent it
From this question How to match this using regex Right now i want to
so I'm in a little over my head right now and want to verify
I've created a custom view class and right now just want to draw an
I have been writing some rspec tests, and right now I want to verify
Right now when I want to redirect after an action in my controller I
Right now, if I want to run mysql, I have to do /Applications/MAMP/Library/bin/mysql -u
Right now I am using sqlite within a ios application, and I want to
right now its set up to write to a file, but I want it
Right now, I have more than 25 vertices that form a model. I want

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.