binding sfdatagrid to a datatable: imagecolumn

Dear Sirs, I have a Datatable which is retrieved from a database table.

MySfDatagrid.DataSource = MyDatatable;

The grid is bound to the datatable and has the appropriate columns retrieved dynamically, that's why I cannot use an IEnumerable object with predefined type elements as in your examples.

I would like to add an image column to my grid, but I cannot find any information in documentation.

I'm also experiencing a problem: if I set

MySfDatagrid.UseWaitCursor = false;
MySfDatagrid.Cursor = Cursors.Hand;

when mouse is hover the grid, cursor still remains the same (no Hand cursor).

Thanks for your suggestion,
L



1 Reply

VS Vijayarasan Sivanandham Syncfusion Team March 23, 2020 02:29 PM UTC

Hi Livio,

Please find answers for your queries below 
Queries 
Answers 
I would like to add an image column to my grid 
Your requirement can be achieved by add Image column dynamically in SfDataGrid and add a image through SfDataGrid.QueryImageCellStyle event. Please refer the below code snippet, 
this.sfDataGrid1.QueryImageCellStyle += SfDataGrid1_QueryImageCellStyle;  
 
private void SfDataGrid1_QueryImageCellStyle(object sender, Syncfusion.WinForms.DataGrid.Events.QueryImageCellStyleEventArgs e) 
        { 
           e.Image = (Image.FromFile(@"..\..\Images\Japan.jpg"));            
        }  
  

mouse is hover the grid, cursor still remains the same (no Hand cursor).

 
You can set the SfDataGrid.UseWaitCursor to false and also set the SfDataGrid.Cursor as Cursor.Hand in SfDataGrid.TableControl.MouseHover event. Please refer the below code snippet, 
this.sfDataGrid1.TableControl.MouseHover += SfDataGrid1_MouseHover;

 
private void SfDataGrid1_MouseHover(object sender, EventArgs e) 
{ 
            this.sfDataGrid1.UseWaitCursor = false; 
            this.sfDataGrid1.Cursor = Cursors.Hand; 
 }  
 
Please let us know, if you need any further assistance on this. 
Regards,
Vijayarasan S 


Loader.
Up arrow icon