ReoGrid Forum

Fast and powerful .NET Spreadsheet Component

You are not logged in.

Announcement

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.

https://github.com/unvell/ReoGrid/issues

#1 2017-03-02 18:45:41

Mussawar
Member
Registered: 2017-02-26
Posts: 4

Getting back the saved image from worksheet in picture box.

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

#2 2017-03-03 04:11:49

Jingwood
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: Getting back the saved image from worksheet in picture box.

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

#3 2017-03-03 08:37:50

Mussawar
Member
Registered: 2017-02-26
Posts: 4

Re: Getting back the saved image from worksheet in picture box.

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

Board footer

Powered by FluxBB