Append image into RichTextBox? help me please

i am using windows(vb.net) rich textbox control. i want to insert
image into richtextbox control. i can do this but the image is pasted to
first line in rich textbox control.
i have two lines in rich textbox i want to insert image in after the
two lines.
is it possible
please help me
millions of thanks in advance
my coding is here

Sub InsertImageIntoRtb(ByVal rtb As RichTextBox, ByVal img As Image)
Clipboard.SetDataObject(img)
rtb.Paste()
End Sub

Sub InsertImageIntoRtb(ByVal rtb As RichTextBox, ByVal imgPath As String)
Dim img As New System.Drawing.Bitmap(imgPath)
InsertImageIntoRtb(rtb, img)
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

InsertImageIntoRtb(RichTextBoxPrintCtrl1, "C:\n_nec\image3\n600i-20001.gif")

End Sub

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

' Print the content of the RichTextBox. Store the last character printed.
checkPrint = RichTextBoxPrintCtrl1.Print(checkPrint, RichTextBoxPrintCtrl1.TextLength, e)

' Look for more pages
If checkPrint < RichTextBoxPrintCtrl1.TextLength Then
e.HasMorePages = True
Else
e.HasMorePages = False
End If

End Sub

Private Sub PrintDocument1_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles PrintDocument1.BeginPrint
checkPrint = 0
End Sub

Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
If PrintDialog1.ShowDialog() = DialogResult.OK Then
PrintDocument1.Print()
End If

End Sub




Answer this question

Append image into RichTextBox? help me please

  • rrobs

    Thank you very much DMan1.



  • Cuno Evertzen

    Try setting the selection point of the rtb before pasting the image:

    Me.RichTextBox1.SelectionStart = Me.RichTextBox1.TextLength



  • Append image into RichTextBox? help me please