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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to display index and images on Row Header?

Thread ID:





150501 Jan 9,2020 08:18 AM UTC Jan 10,2020 02:23 PM UTC WinForms 1
Tags: SfDataGrid
Asked On January 9, 2020 08:18 AM UTC

Hello Dear support.
Firstly, I would thank you for your good support !
Secondly, I have the following quastions :
 1) How to show the numbred Row Header and icons in the same RowHeader Cell?
 2) How to resize automatically the RowHeader Cell to fit its contnent ?
Best regards

Saravanan Ayyanar [Syncfusion]
Replied On January 10, 2020 02:23 PM UTC

Hi Cosyspro, 
Thank you for using Syncfusion controls. 
Please find the below your query response, 
How to show the number Row Header and icons in the same RowHeader Cell ? 
You can achieve your requirement of “Show the numbers and Icons in the same RowHeaderCell by using the DrawCell event. Please refer the below code snippet. Please find the sample link below the table. 
sfDataGrid.DrawCell += sfDataGrid_DrawCell; 
void sfDataGrid_DrawCell(object sender, Syncfusion.WinForms.DataGrid.Events.DrawCellEventArgs e) 
    if (sfDataGrid.ShowRowHeader && e.RowIndex != 0) 
        if (e.ColumnIndex == 0) 
            e.Handled = true; 
            Rectangle rect = new Rectangle(e.Bounds.X + 3, e.Bounds.Y + 10, e.Bounds.Width - 3, e.Bounds.Height - 5); 
            e.Graphics.FillRectangle(new SolidBrush(sfDataGrid.Style.RowHeaderStyle.BackColor), new Rectangle(e.Bounds.X + 1, e.Bounds.Y + 1, e.Bounds.Width - 1, e.Bounds.Height - 1)); 
            e.Graphics.DrawImage(new Bitmap(Image.FromFile(@"../../search.png")), e.Bounds.X + 30, e.Bounds.Y +3); 
            e.Graphics.DrawString(e.RowIndex.ToString(), new System.Drawing.Font("Calibri", 12), new System.Drawing.SolidBrush(System.Drawing.Color.Black), e.Bounds.X + 3, e.Bounds.Y+5);   
            e.Graphics.DrawLine(new Pen(ColorTranslator.FromHtml("#CCCCCC")), e.Bounds.Right, e.Bounds.Top, e.Bounds.Right, e.Bounds.Bottom); 
            e.Graphics.DrawLine(new Pen(ColorTranslator.FromHtml("#CCCCCC")), e.Bounds.Left, e.Bounds.Bottom, e.Bounds.Right, e.Bounds.Bottom); 
UG Link: 
How to resize automatically the RowHeader Cell to fit its content ? 
Currently, we are not provided the support to resize the RowHeaderCell. You can achieve your requirement  by setting the SfDataGrid.HeaderRowWidth. Please refer the below code snippet. Please find the sample link below the table. 
sfDataGrid.RowHeaderWidth = 70; 
UG Link: 
Sample Link: 
Please let us know, if you require further assistance on this. 
Saravanan A. 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon