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. Image for the cookie policy date
close icon

Images not showing after grouping

Dear Syncfusion,

After my previous post (https://www.syncfusion.com/forums/148556/gridimagecolumn-not-working) I tried to group the content of my grid and mostly it works only the images are not showing.

Before grouping:


After grouping:
"this.sfDataGrid1.GroupColumnDescriptions.Add(new GroupColumnDescription() { ColumnName = "DocumentName" });"


How can I group by "Document name" and still show the country flag image in the Country column?

PS: The project is a simple Windows Forms Project using C# with a single sfDataGrid in it. Basically it's the same project as in my previous question (linked above)
PS PS: Change the paths of the images inside VerwerkingsInfoCollection.cs to make it work on your computer.

Attachment: UpdateMasterExcelDocument_dafa884f.zip

1 Reply

MA Mohanram Anbukkarasu Syncfusion Team October 29, 2019 07:13 AM UTC

Hi Dimitri, 

Thanks for contacting Syncfusion support. 

We have checked the reported scenario. You can resolve this by considering the group column description count while specifying the column index to draw the image as shown in the following code example. 

Code example

void sfDataGrid_DrawCell(object sender, Syncfusion.WinForms.DataGrid.Events.DrawCellEventArgs e) 
{ 
    if (e.DataRow.RowType == RowType.DefaultRow && e.ColumnIndex == this.sfDataGrid.GroupColumnDescriptions.Count + 1) 
    { 
        e.Handled = true; 
        e.Graphics.DrawImage(Image.FromFile(@"../../US.jpg"), new Rectangle(e.Bounds.X + 50, e.Bounds.Y + 2, e.Bounds.Width - 100, e.Bounds.Height - 5)); 
        Pen borderPen = new Pen(Color.LightGray); 
        e.Graphics.DrawLine(new Pen(e.Style.Borders.Right.Color), e.Bounds.Right - 1, e.Bounds.Top, e.Bounds.Right - 1, e.Bounds.Bottom); 
        e.Graphics.DrawLine(new Pen(e.Style.Borders.Bottom.Color), e.Bounds.Left, e.Bounds.Bottom - 1, e.Bounds.Right, e.Bounds.Bottom - 1); 
    } 
} 

 


Please refer the sample from the following link. 


Please let us know if you need further assistance from us. 

Regards, 
Mohanram A. 


Loader.
Live Chat Icon For mobile
Up arrow icon