simonalexander2005 simonalexander2005 - 18 days ago 7
C# Question

Copy Tooltip text from RichTextBox instead of Controls.image

The problem

So I have a

System.Windows.Controls.RichTextBox
, which contains
Paragraph
s, containing
Run
s, containing either text or
System.Windows.Controls.Image
objects.

The images have
Tooltip
s on them, describing what they do (not that you can see them when you hover in the
RichTextBox
.)

When I select and copy (
ctrl-c
) the contents of the
RichTextBox
, I want to copy the description of the image, rather than the image itself; and keep the rest of the text the same.

So, for example:

INFO: program is working!

would be copied as

"INFO: program is working!"

My ideas so far

I guess I would have to manually capture the event when text is copied from the
RichTextBox
(is there one?), and replace the contents of the clipboard by hand? Does the clipboard store the
Tooltip
information when the
Image
is copied? If not, is there any other way I could automatically get that information?

Answer

As the comment by @Sinatr says, the best way is to use the clipboard change event handlers and manually replace.