以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  如何插入图片文件  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=80033)

--  作者:blackzhu
--  发布时间:2016/1/14 14:17:00
--  如何插入图片文件
RichTextBox 如何插入图片文件
--  作者:blackzhu
--  发布时间:2016/1/14 14:22:00
--  
If Forms("聊天").Opened Then
    Dim ct As Windows.Forms.RichTextBox
    ct = Forms("聊天").Controls("Panel1").BaseControl.Controls("ct")
\'System.Windows.Forms.RichTextBoxStreamType.PlainText
    Dim img As Image = Image.FromFile(ProjectPath & "Images\\" & e.Sender.Name)
    Clipboard.SetDataObject(img)
    ct.Paste()
    
    
End If

怎么改
[此贴子已经被作者于2016/1/14 14:22:49编辑过]

--  作者:Hyphen
--  发布时间:2016/1/14 14:58:00
--  
Dim richTextBox1 As new Windows.Forms.RichTextBox
richTextBox1.Location = new System.Drawing.Point(12, 60)
richTextBox1.Name = "richTextBox1"
richTextBox1.Size = new System.Drawing.Size(312, 236)

e.Form.Controls("Panel1").basecontrol.controls.add(richTextBox1)

Dim dlg As new OpenFileDialog
If dlg.ShowDialog = DialogResult.Ok Then
    Dim bmp = new Bitmap(dlg.FileName)
    Clipboard.SetDataObject(bmp)\'将数据置于系统剪贴板中
    Dim dataFormat = System.Windows.Forms.DataFormats.GetFormat(System.Windows.Forms.DataFormats.Bitmap)\'格式
    If richTextBox1.CanPaste(dataFormat) Then
        richTextBox1.Paste(dataFormat)
    End If
End If

--  作者:blackzhu
--  发布时间:2016/1/14 15:19:00
--  
我记下你这. 但是我已经搞定了  我现在又要做判断了,要发送到另外一个富文本中去.
--  作者:blackzhu
--  发布时间:2016/1/14 15:38:00
--  
如何获取富文本中的图片 文件等等的路径信息
--  作者:Hyphen
--  发布时间:2016/1/14 15:51:00
--  
Dim richTextBox1 As Windows.Forms.RichTextBox

richTextBox1 = e.Form.Controls("Panel1").BaseControl.Controls(0)
If richTextBox1 IsNot Nothing Then
    Dim img1 = ctype(Clipboard.GetData(System.Windows.Forms.DataFormats.Bitmap),Image)
    If img1 IsNot Nothing Then
        
        e.Form.Controls("PictureBox1").image = img1
    End If
End If

--  作者:blackzhu
--  发布时间:2016/1/14 16:08:00
--  
我试试


--  作者:blackzhu
--  发布时间:2016/1/14 16:45:00
--  
我在选择图片的时候吧图片写入了一个路径

  If Vars("路径") > "" Then
        Dim MyImageFile As String = Vars("路径")
        Dim bmp = new Bitmap(MyImageFile)
        Clipboard.SetDataObject(bmp)\'将数据置于系统剪贴板中
        Dim dataFormat = System.Windows.Forms.DataFormats.GetFormat(System.Windows.Forms.DataFormats.Bitmap)\'格式
        If ct.CanPaste(dataFormat) Then
            ct.Paste(dataFormat)
            r("文件名") = MyImageFile
        End If
    End If

 但是这样写了以后 没有办法从 富文本1添加到富文本2

--  作者:Hyphen
--  发布时间:2016/1/14 17:16:00
--  
富文本1选中图片,右键菜单复制,然后取得图片对象,发给富文本2,用6楼的方法

如果知道本地文件路径,直接按3楼的方法粘贴到富文本2就可以。



--  作者:布莱克朱
--  发布时间:2016/1/14 17:50:00
--  
我已经获取了 路径 但是用


 If Vars("路径") > "" Then
        Dim MyImageFile As String = Vars("路径")
        Dim bmp = new Bitmap(MyImageFile)
        Clipboard.SetDataObject(bmp)\'将数据置于系统剪贴板中
        Dim dataFormat = System.Windows.Forms.DataFormats.GetFormat(System.Windows.Forms.DataFormats.Bitmap)\'格式
        If ct.CanPaste(dataFormat) Then
            ct.Paste(dataFormat)
            r("文件名") = MyImageFile
        End If
    End If

就是无效