Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15463

Paste Image to Rich Tect Box issue

$
0
0
Hi.
I'm having some issue with pasting a list of images to the RTB.
I'm using an list with images, I'm also using the same image object as you can see on the code.
The problem is that, SOMETIMES, the RTB will skip an image here and there. If i step into a next node (I have a treeview and calling the code on TreeView1.AfterSelect) then it will get all the images. As I can see, the problem will go away if I go back and forth on the treeview nodes. It seems to happen the first time the AfterSelect event hits and , again, not always.
The code runs synchronous as it's a very fast calculation.
I've tried to use a thread.sleep in some of the image changes but it's about 30 image changes so even if it works it will slow down the app.
Any thoughts?
Maybe the problem is the clipboard not catching up? In that case is there another way to paste images on RTB (besides creating my own clipboard, that is a real pain)?
Code:

  Dim img As Image
  img = Imagelst(0).imageRTB
  Clipboard.SetImage(img)
  RichTextBox1.Paste()
RichTextBox1.AppendText(vbCrLf) 
 RichTextBox1.AppendText("something & vbCrLf)

RichTextBox1.AppendText(vbCrLf)
 img = Imagelst(1).imageRTB
  Clipboard.SetImage(img)
  RichTextBox1.Paste()
RichTextBox1.AppendText(vbCrLf) 
 RichTextBox1.AppendText("somethingelse & vbCrLf)

...etc


Viewing all articles
Browse latest Browse all 15463

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>