You are not logged in.
This forum has been archived and no longer accepts new user registrations. Please report your questions, problems, and feedback to the issue page of ReoGrid on GitHub. Thank you for your cooperation.
Hi,
Currently I'm exploring this wonderful component and become able to add image in to worksheet (.rgf format).
Sorry, but I use VB.NET because I'm previously using it. Here is code I'm using to add image in to worksheet by clicking a button:
Private Sub btnAddPicture_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddPicture.Click
Dim img = Image.FromFile("Pictures/ABC.jpg")
Dim imageObject = New unvell.ReoGrid.Drawing.ImageObject(img)
Grid1.CurrentWorksheet.FloatingObjects.Add(imageObject) 'Grid1 in the name of my control
imageObject.Bounds = New unvell.ReoGrid.Graphics.Rectangle(40, 40, 60, 60)
End Sub
Now I want to get this image back from worksheet and put it in to a picture box by clicking a button.
Private Sub btnGetPicture_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btngetPicture.Click
PictureBox1.Image = ' I want that image in this picture box
End Sub
Sorry if my code look silly and substandard but please consider me at almost beginner level. I tried to use online translator to convert code given in documentation from C# to vb.net but no success. Please help. I need code in vb.net.
Thanks.
Offline
You can get back images from floating objects, please refer to this topic:
https://reogrid.net/walkthroughs/read-a … xcel-file/
This is in C# but the method is same.
Offline
Thanks. Actually I was having problem with type casting. Now this code is working good for me with a button click. VB.NET
Private Sub btnGetPicture_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetPicture.Click
Dim worksheet = Grid1.Worksheets("sheet1")
For Each floatingObject In worksheet.FloatingObjects
Dim imageObject = DirectCast(floatingObject, Drawing.ImageObject)
PictureBox1.Image = imageObject.Image 'image
Next
End Sub
Thanks for your support.
Offline