C1RichTextBox Paste

Posted by: patrick.muellner on 4 December 2023, 12:50 am EST

  • Posted 4 December 2023, 12:50 am EST

    Hi,

    which options do I have, if I want to prevent large graphic files from being inserted into the C1RichTextBox?

    Regards

  • Posted 4 December 2023, 8:19 pm EST

    Hi Patrick,

    You can handle C1RichTextBox’s ClipboardPasting event and check if the Clipboard file does not meet the required criteria. Here is the code-snippet that restricts user from inserting large image files into the C1RichTextBox:

    private void rtb_ClipboardPasting(object sender, C1.WPF.RichTextBox.Documents.ClipboardEventArgs e)
    {
        if (Clipboard.ContainsImage())
        {
            BitmapSource img = Clipboard.GetImage();
            if(img.Height > 500 && img.Width > 500)
            {
                e.Handled = true;
                MessageBox.Show("File size is too large...");
            }
        }
    }

    Kindly refer to the attached sample for full implementation. See BlockLargeFilesRTB.zip.

    Thanks & Regards,

    Aastha

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels