ReadOnly content of RichTextBox doesn't show images

本小妞迷上赌 提交于 2019-12-24 13:37:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!