insert IMAGE IN RICHTEXTBOX

User avatar
sal21
PlatinumLounger
Posts: 4353
Joined: 26 Apr 2010, 17:36

insert IMAGE IN RICHTEXTBOX

Post by sal21 »

I just have an in image in picturebox.
ho to insert this picturebox in the head of richtexbox?

User avatar
HansV
Administrator
Posts: 78448
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: insert IMAGE IN RICHTEXTBOX

Post by HansV »

Perhaps Insert Pictures helps.
Best wishes,
Hans

User avatar
SpeakEasy
4StarLounger
Posts: 548
Joined: 27 Jun 2021, 10:46

Re: insert IMAGE IN RICHTEXTBOX

Post by SpeakEasy »

Not sure what you mean by "head of richtexbox"

Assuming that you are talking VB6, here's one way to get an image into a richtexbox at the current insertion point:

Code: Select all

    Dim mypic As New StdPicture
    Set mypic = LoadPicture("C:\Program Files\Microsoft Visual Studio\Common\Graphics\Bitmaps\Assorted\spade.bmp")
    
    Clipboard.SetData mypic
    RichTextBox1.SetFocus
    SendKeys "^V"

User avatar
sal21
PlatinumLounger
Posts: 4353
Joined: 26 Apr 2010, 17:36

Re: insert IMAGE IN RICHTEXTBOX

Post by sal21 »

HansV wrote:
21 Oct 2021, 18:17
Perhaps Insert Pictures helps.
TKS.

But resolved with:

Code: Select all

Private Sub Command2_Click()

    Picture1.AutoRedraw = True
    Me.RichTextBox2.Text = ""
    Clipboard.Clear
    Clipboard.SetData Picture1.Picture
    RichTextBox2.SelStart = 0
    RichTextBox2.SelAlignment = 2
    SendMessage Me.RichTextBox2.hWnd, WM_PASTE, 0, 0
Me.RichTextBox2.text="test"
End Sub
only a prob!


when i print a new line with:
Me.RichTextBox2.text="test", the image is cleared!

Peraphs before to print a new text line i move the cursor, under image...

User avatar
HansV
Administrator
Posts: 78448
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: insert IMAGE IN RICHTEXTBOX

Post by HansV »

Perhaps

Code: Select all

    Me.RichTextBox2.Text = Me.RichTextBox2.Text & "test"
Best wishes,
Hans