We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Display Image from file based on value of a property

Thread ID:

Created:

Updated:

Platform:

Replies:

128010 Dec 24,2016 09:14 PM Jan 23,2017 12:03 AM Windows Forms 10
loading
Tags: GridGroupingControl
George Busby
Asked On December 24, 2016 09:14 PM

I have a database table that has a property with the string value of an image file on the system (i.e. "C:\Users\George\Pictures\2013 11-11-13\IMG_20130607_215118_134.jpg". I want to display the image in a cell within the grid. I am new to Syncfusion controls and can not figure out how to get this to work. 

Mohanraj Gunasekaran [Syncfusion]
Replied On December 27, 2016 05:39 AM

Hi George, 

Thanks for using Syncfusion products. 

We have already provided the KB regarding image loading in grid cell, 

Note: In attached sample, we have created the ImageList and added the Image using following code. You can replace your image file location instead of the below highlighted location to load your image in the grid cell. 
 
Code snippet: 
ImageList image = new ImageList(); 
image.Images.Add(Image.FromFile(@"\..\..\Images\logo1.jpg")); 

If you provide the image path as a cell value, you can get this value using e.Style.CellValue in QueryCellStyleInfo event. Then you can get the image from provided path. Please refer the below code snippet,  
Code snippet: 
this.gridGroupingControl1.QueryCellStyleInfo += gridGroupingControl1_QueryCellStyleInfo; 
ImageList image = new ImageList(); 
void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e) 
{ 
   if (e.TableCellIdentity != null && e.TableCellIdentity.Column != null 
    && e.TableCellIdentity.Column.Name == "ImageColumn" && e.TableCellIdentity.TableCellType != GridTableCellType.ColumnHeaderCell)     
    { 
        e.Style.CellType = GridCellTypeName.Image; 
        //image collection is stored in this list 
        if (File.Exists(e.Style.CellValue.ToString())) 
        { 
            image.Images.Clear(); 
            image.Images.Add(Image.FromFile(e.Style.CellValue.ToString())); 
        } 
        e.Style.ImageList = image; 
        //index of the image to be added. 
        e.Style.ImageIndex = 0; 
    } 
} 

The below documentation link can be helpful to use our GridGroupingControl, 

Regards, 
Mohanraj G. 


George Busby
Replied On December 30, 2016 11:57 AM

I updated my code ( using VB) but when I execute the code I get this error message. I stepped through the code in debug mode and this error message appeared after successfully walking through all of the code.

Symbol File not loaded
No symbol file loaded for Syncfusion.Grid.Windows.dll
Module Information 
Version: 14.3460.0.49
Original Location: D:\Visual Studio 2015\Projects\PhotoDirectory2016\PhotoDirectory2015\bin\Debug\Syncfusion.Grid.Windows.dll

Symbol load information
Binary was not built with debug information

George Busby
Replied On December 30, 2016 05:29 PM

I installed version 14.4.0.15 and Webroot detected a threat during the install

Malware Group:
W32.Malware.Gen

file: startdexplorecrl.exe

Mohanraj Gunasekaran [Syncfusion]
Replied On January 2, 2017 07:39 AM

Hi George, 

Please find your responses in below table, 
I installed version 14.4.0.15 and Webroot detected a threat during the install 
 
Malware Group: 
W32.Malware.Gen 
 
file: startdexplorecrl.exe 


We have updated the response through your incident. So please login your account and find the response in your created incident. 
Symbol File not loaded 
No symbol file loaded for Syncfusion.Grid.Windows.dll 

We are not able to reproduce your scenario at our end. We suspect symbol file were loading from your local machine please find the response in below table 

Solution 1: 
The reported scenario can be resolved by unload the solution file and delete the bin, obj file for the solution. Now reload and build the solution. 

Solution 2: 
In order to resolve the issue, please follow the below steps, 
1.       Tools -> Options -> Debugging -> Symbols and pressed Empty Symbol Cache in your visual studio. 
2.       Click on ok button. 






If you are still facing this issue, please provide the sample or modify the below attached sample to reproduce your scenario. It will helpful to provide the solution at the earliest. 

Sample link: GridGroupingControl 


Regards, 
Mohanraj G. 
 


George Busby
Replied On January 4, 2017 09:25 PM

I cleared the Symbol cache and now I am getting an error thread.cs not found. Also a window pops up with the message:
An unhandled exception of type 'System.NullReferenceException' occurred in Syncfusion.Grid.Windows.dll

Here is the code. It is a form  (Form4) that only has one gridgrouping control addded (gridGroupingControl1)

Public Class Form4
    Private Sub Form4_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'AmGavDirectoryDataSet.PhotoDirectoryList' table. You can move, or remove it, as needed.
        Me.PhotoDirectoryListTableAdapter.Fill(Me.AmGavDirectoryDataSet.PhotoDirectoryList)
        AddHandler Me.GridGroupingControl1.QueryCellStyleInfo, AddressOf gridGroupingControl1_QueryCellStyleInfo
    End Sub
    Private Sub gridGroupingControl1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs)
        If e.TableCellIdentity IsNot Nothing Then
            If e.TableCellIdentity.Column IsNot Nothing Then
                If e.TableCellIdentity.Column.Name = "Photo" And e.TableCellIdentity.TableCellType <> GridTableCellType.ColumnHeaderCell Then
                    e.Style.CellType = GridCellTypeName.Image
                    Dim Myimage As New ImageList
                    'image collection is stored in this list
                    If (File.Exists(e.Style.CellValue.ToString())) Then
                        Myimage.Images.Clear()
                        Myimage.Images.Add(Image.FromFile(e.Style.CellValue.ToString()))
                        e.Style.ImageList = Myimage
                        'index of the image to be added. 
                        e.Style.ImageIndex = 0
                    End If
                End If
            End If
        End If
    End Sub

End Class

Mohanraj Gunasekaran [Syncfusion]
Replied On January 5, 2017 06:04 AM

Hi George, 

Sorry for the inconvenience caused. 

We have tried to reproduce your scenario, but we are not able to reproduce your scenario at our end. Here we have provided the sample as like your customization. In our sample, we have bound the BindingList with GridGroupingControl. In this BindingList, we have used the Picture property to save the image path and load the image from the path for the Picture column using QueryCellStyleInfo event. Please refer the below code snippet and refer the below attached sample.  

Code snippet 
' DataSource 
Dim dataSource As New DataCollection() 
Dim rand As New Random() 
Dim r As Integer = rand.Next(100) 
For i As Integer = 0 To 5 
     dataSource.Add(New Data(r.ToString(), "Category" & r.ToString(), "Desc" & r.ToString(), r.ToString() & "Data", FindFile("\Images\image" & (r Mod 4).ToString() & ".jpg"))) 
     r = rand.Next(100) 
Next i 
 
AddHandler Me.gridGroupingControl1.QueryCellStyleInfo, AddressOf gridGroupingControl1_QueryCellStyleInfo 
 
Private Sub gridGroupingControl1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs) 
If e.TableCellIdentity IsNot Nothing Then 
      If e.TableCellIdentity.Column IsNot Nothing Then 
         If e.TableCellIdentity.Column.Name = "Picture" And e.TableCellIdentity.TableCellType <> GridTableCellType.ColumnHeaderCell Then 
              e.Style.CellType = GridCellTypeName.Image 
              Dim Myimage As New ImageList 
              'image collection is stored in this list 
               Dim path As String = e.Style.CellValue.ToString() 
               If (Not String.IsNullOrEmpty(e.Style.CellValue.ToString()) And File.Exists(path)) Then 
                    Myimage.Images.Clear() 
                    Dim img As Image = Image.FromFile(path) 
                    Myimage.Images.Add(img) 
                    e.Style.ImageList = Myimage 
                    'index of the image to be added.  
                    e.Style.ImageIndex = 0 
               End If 
           End If 
       End If 
   End If 
End Sub 

Sample link: GridGroupingControl 

If we missed anything in our sample, please modify the sample or provide the sample to reproduce your scenario. It will be helpful to provide the solution at the earliest. 

Regards, 
Mohanraj G 


George Busby
Replied On January 6, 2017 10:27 PM

I uninstalled Syncfusion and removed all references to it from my vb project then reinstalled syncfusion Windows Forms. I then  replaced my code with your sample and walked through the code in debug. Once I passed the line
 If e.TableCellIdentity.Column.Name = "Picture" And e.TableCellIdentity.TableCellType <> GridTableCellType.ColumnHeaderCell Then

I received the following error
Operators.vb not Found

Mohanraj Gunasekaran [Syncfusion]
Replied On January 9, 2017 07:43 AM

Hi George, 

Thanks for your update. 

We could understand your reported scenario. But unfortunately we are not able to reproduce your scenario in our sample. Can you please conform whether the issue is reproduced in our provided sample or only in your application? 

Note: 
If this issue is occurring only in your sample, please follow the below steps to resolve this issue, 

·         If the project files is copied from your machine to another machine with (.suo) file. Delete that (.suo) file then clean and build the solution. 
·         Please ensure the below configurations are enabled in your machine, 
o   Tools>Options>Debugging>General and checked the Enable Just My Code checkbox so that the debugger is only debugging by your code. 
o   Tools>Options>Debugging>General and then click the checkbox next to Step Over Properties And Operators (Managed Only). 

If the reported issue still persists, please provide your sample. It would be more helpful for us to provide solution at the earliest. 

Regards, 
Mohanraj G. 


George Busby
Replied On January 22, 2017 02:16 PM

The  Tools>Options>Debugging>General and checked the Enable Just My Code fixed the issue. 

Mohanraj Gunasekaran [Syncfusion]
Replied On January 23, 2017 12:03 AM

Hi George,  
 
Thanks for your update.  

We are glad to know that your reported problem has resolved. Please let us know if you have any further assistance. 

Regards, 
Mohanraj G.  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;