I am trying to make a DataGrid in a desktop windows form application where the first column contains a picture. I found many examples but none for the desktop windows form version. It shows all the data (strings, ints bools) correctly, only it shows no images (it just shows blank cells).
What I have:
In the designer I have a sfDataGrid named sfDataGrid1
We have analyzed your requirement to load image using GridImageColumn in SfDataGrid. On further analyzing the code files that you have shared with us, we found that ImageSource is referred from Xamarin.Forms and you are using Winforms SfdataGrid. By default, Winforms SfDataGrid does not have support for ImageSource.
However, you can achieve this by using Image and SfDataGrid.DrawCell method. We have prepared a demo sample based on the code files shared and please find the sample from the link below
Only this line takes 1 specific image "../../US.jpg" and uses the same image for the whole column. And does not uses the provided Image data from VerwerkingsInfoCollection.cs. I have tried some things myself (see zip) but I can't manage to correct the method so that it uses the provided images.
PS: the variable "object sender" does have the correct data including the images that I need but if I make a foreach loop (see new zip) it just uses the last image in the for loop for the whole column.
EDIT: The second I posted this it occurred to me how to fix it. My apologies if you have read it before my edit.
This is how I changed the code for the people who have the same problem as I did and also want to solve it: The following line "this.sfDataGrid1.DrawCell += sfDataGrid_DrawCell;" uses a DrawCell event that fires for each cell that needs drawing. So if you change the "sfDataGrid_DrawCell" method to the following it will look for the right image in the DataSource.