Showing the Numbered Row Header

I am trying to draw the increased row number. For this I am following this tutorial: https://help.syncfusion.com/windowsforms/datagrid/rows#showing-the-numbered-row-header


Unfortunately I can't do it when I have a list like detailsview.


Is it possible to put numbers only in the header row and not in the details?


Captura de pantalla 2022-08-23 174122.jpg



1 Reply

DM Dhanasekar Mohanraj Syncfusion Team August 24, 2022 05:19 PM UTC

Hi Sergio Ayala,

You can achieve your requirement to show the record index for the parent Datagrid alone using the below code snippet,

this.sfDataGrid1.DrawCell += SfDataGrid1_DrawCell;

private void SfDataGrid1_DrawCell(object sender, Syncfusion.WinForms.DataGrid.Events.DrawCellEventArgs e)

{

    if (sfDataGrid1.ShowRowHeader && e.RowIndex != 0 && e.DataRow.RowType == Syncfusion.WinForms.DataGrid.Enums.RowType.DefaultRow)

    {

        if (e.ColumnIndex == 0)

        {

            int index = this.sfDataGrid1.View.Records.IndexOfRecord(e.DataRow.RowData as OrderInfo);

            e.DisplayText = (index + 1).ToString();

        }

 

    }

}


We have prepared the sample based on your requirement. Please find the sample in the attachment and let us know if you have any concerns about this.

Regards,

Dhanasekar M.


If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.



Attachment: DetailsViewDemo_WF_5ad5dd1b.zip

Loader.
Up arrow icon