问题
I've come across some strange behavior of RichTextBox
. I want it to be readonly
, but then it doesn't display images when I use
richTextBox.LoadFile(path)
method to load .rtf
file. When it's not readonly
the file is loaded correctly and the images are displayed. I am using Windows Forms.
Can I make it up somehow or is it another RTB
bug? For now, as a workaround I am using a label to move focus to it while my RTB
got focus, but I don't really like this one.
回答1:
you can create a custom RichTextBox implementation with a method to set RTF content which captures readonlystate, set the richtextbox to ReadOnly = false, set RTF content then set ReadOnly as it originally was.
来源:https://stackoverflow.com/questions/34843931/readonly-content-of-richtextbox-doesnt-show-images