VB.NET如何让RichTextbox中显示图片?

DoubleVoid 2012-03-30 09:07:19
RichTextbox直接拖进来的图片就是一个图标,我想让它在RichTextbox中直接显示,有办法吗?
...全文
399 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
pltop_com 2012-04-02
  • 打赏
  • 举报
回复
看看这个帖子:
http://topic.csdn.net/u/20110318/18/93763e72-7033-4078-b3c1-19ef44c6bbe8.html?27194
沐NeMo 2012-04-02
  • 打赏
  • 举报
回复
楼上的:哈哈,原来是一年前我回复人家的帖子。
参考:
http://www.codeproject.com/KB/edit/csexrichtextbox.aspx
用到类型下面的代码:

Private Sub AddImage()
Dim img As Image = Image.FromFile("C:\image.jpg")
Clipboard.SetImage(img)
Me.RichTextBox1.Paste()
Clipboard.SetImage(My.Resources.SomeImage)
Me.RichTextBox1.Paste()
End Sub




参考:方法,代码。
http://www.windowsdevelop.com/windows-forms-general/insert-images-into-richtextbox-in-c-13879.shtml


Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim format As DataFormats.Format = DataFormats.GetFormat(DataFormats.Bitmap)
' After verifying that the data can be pasted, paste
If Me.richTextBox1.CanPaste(myFormat) Then
richTextBox1.Paste(format)
End If
End Sub

Private Sub richTextBox1_Click(ByVal sender As Object, ByVal e As EventArgs)
If ((Me.richTextBox1.SelectionType = RichTextBoxSelectionTypes.Object) _
AndAlso (Me.richTextBox1.SelectedRtf.IndexOf("\pict\wmetafile") <> -1)) Then
MessageBox.Show("image clicked!")
End If
End Sub

16,553

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧