Rich Text box image Insertion Problem

Progress2007

Active member
Joined
Sep 5, 2008
Messages
25
Programming Experience
1-3
Hi
I have a richText box, and wht i want that there is a context menu for Copy , cut and paste.

Wht i want that user could select a image and could paste into this rich text box..

Please tell me how can i do this.

I don;t want user to select Image from Open File Dialog box.

Thnx
 
Add a ContextMenuStrip Control and add the Copy/Cut/Paste menu items, assign it to the RichTextBox. Add the code for the menu items Click event, for Paste it would be:
VB.NET:
Expand Collapse Copy
rtb.Paste()
If the user has copied an image to clipboard it will be pasted into the RichTextBox.
 
Add a ContextMenuStrip Control and add the Copy/Cut/Paste menu items, assign it to the RichTextBox. Add the code for the menu items Click event, for Paste it would be:
VB.NET:
Expand Collapse Copy
rtb.Paste()
If the user has copied an image to clipboard it will be pasted into the RichTextBox.

Hi john..... Thanks for your response.

but problem is that if u will will just copy and image from somewhere and will paste with the help of rtb.paste(), it will not paste that image. Actullay a rectangle will be paste containing a lable jpeg image in the middlle.

The Image is not displaying at all. Please suggest me how can i do this.....
 
How about something like
VB.NET:
Expand Collapse Copy
Dim img As Image = Image.FromFile("C:\image.jpg")

Clipboard.SetImage(img)
Me.RichTextBox1.Paste()
 
How about something like
VB.NET:
Expand Collapse Copy
Dim img As Image = Image.FromFile("C:\image.jpg")

Clipboard.SetImage(img)
Me.RichTextBox1.Paste()


Hey thnx for ur response. This solution will only work if that file is stored at the hard disk.
what if some one copy an image from a word file and want to paste that image into Rich text box.

suggest me if u hv ny solution of this.
 
When an image is copied from Word or a webpage for example the Paste method will paste the image into the RTB. If the user copies a image file in Windows Explorer then the clipboard will contain the path for that image. You can use the Clipboard object to examine what content it has, for example with the ContainsImage and ContainsFileDropList methods.
 
Back
Top