Row Headers Will Not Hide

Hi: I have tried several methods and reviewed your examples elsewhere in these forums but have been unsuccessful in hiding the header row. Please see the attached image and code files. What appears in the header are the mapping names for the data used to build the grid. 

Separate note: The "drag files here" feature of this page does not allow text or jpg files. Makes it a bit clunky to share items. 

Thanks


private void InitializeGrid()

{

    this.Dock = DockStyle.Fill;

    this.AutoGenerateColumns = false;

    this.AllowEditing = true;

    this.RowHeight = 200;

    this.AutoSizeColumnsMode = AutoSizeColumnsMode.None;

    this.SelectionMode = GridSelectionMode.Single;

    this.NavigationMode = NavigationMode.Cell;





    // Remove grid borders

    this.Style.BorderStyle = BorderStyle.None;

    this.Style.CellStyle.Borders.All = new GridBorder(GridBorderStyle.None);

    this.Style.HeaderStyle.Borders.All = new GridBorder(GridBorderStyle.None);




    // Enable column resizing - this is the correct property for WinForms SfDataGrid

    this.AllowResizingColumns = true;


    // Add scroll event handler

    this.QueryRowHeight += OnQueryRowHeight;


    // Turn off row headers

    this.ShowRowHeader = false;




    // Adjust size to fit within the parent panel

    this.SizeChanged += (s, e) =>

    {

        if (this.Parent != null)

        {

            var parentPanel = this.Parent.Controls.OfType<Panel>().FirstOrDefault(p => p.Dock == DockStyle.Right);

            if (parentPanel != null)

            {

                this.Width = this.Parent.ClientSize.Width - parentPanel.Width;

            }

        }

    };

}

 




10 Replies 1 reply marked as answer

MS Malini Selvarasu Syncfusion Team March 17, 2025 01:44 PM UTC

Hi Tom Dennison,
 

Query

Response

Hi: I have tried several methods and reviewed your examples elsewhere in these forums but have been unsuccessful in hiding the header row. Please see the attached image and code files. What appears in the header are the mapping names for the data used to build the grid. 

 

Based on the provided information, we understand that you need to hide the header row. This can be achieved by setting the SfDataGrid.HeaderRowHeight property to zero.

Code Snippet:

this.sfDataGrid.HeaderRowHeight = 0;

 

 

Separate note: The "drag files here" feature of this page does not allow text or jpg files. Makes it a bit clunky to share items. 

We have created a new forum for this query. Please follow up on the forum for further updates.
Forum Link : Images Not Allowed in 'Drop File Here | Syncfusion Forum Assist - Split From 196373 | Others Forums | Syncfusion®


Regards,
Malini Selvarasu



TD Tom Dennison March 17, 2025 11:35 PM UTC

Hi - Thank you for the response. I have replaced my existing code of:

this.ShowRowHeader = false;


 With the suggested code of:

  // Turn off row headers

  this.ShowRowHeader = false;


Unfortunately the header row still appears. 



MS Malini Selvarasu Syncfusion Team March 18, 2025 02:50 PM UTC

Hi  Tom Dennison,


Based on the information provided, we are a little unclear about whether you are trying to hide the RowHeader or ColumnHeader.

We have provided an image of the RowHeader and ColumnHeader, along with details on how to hide both headers.
 

Header

Image

Response

RowHeader

 

 

You can hide the Row Header by setting ShowRowHeader to false. Based on this, the Row Header will be hidden properly.

 

Code Snippet:

this.sfDataGrid1.ShowRowHeader = false;

HeaderRow


 

 

You can hide the HeaderRow by the SfDataGrid.HeaderRowHeight property to zero.
 

Code Snippet:

this.sfDataGrid.HeaderRowHeight = 0;


User Guide Documentation for Row Header: Rows in WinForms DataGrid Control | Syncfusion®
User Guide Documentation for HeaderRow : Rows in WinForms DataGrid Control | Syncfusion®

Please review the above solution and let us know if it resolve your issue, thank you for your understanding.

Regards,
Malini Selvarasu



TD Tom Dennison March 18, 2025 03:04 PM UTC

Hi: Sorry for the confusion. Yes, I am in fact trying to hide the header row. I have implemented the code to set the size to zero but the issue remains. I am doing this in initializeGrid which is called from the constructor. If you would like to see the entire section of code I can provide it. Do you have a secure method to upload it?



MS Malini Selvarasu Syncfusion Team March 19, 2025 01:18 PM UTC

Hi Tom Dennison,

Based on the information provided, we understand that you are trying to hide the header row of the SfDataGrid. We have prepared a sample based on the code snippet from the initial update, but we were unable to reproduce the issue. In our test, the header row was hidden properly.
To assist you further, we kindly request the following additional details:
  • Can you share your data settings for SfDataGrid?
  • Modified Sample: If possible, modify the attached sample to reproduce the issue and share it with us.
These details will help us better understand the problem and provide a timely resolution.
Note: You can share your code files in this forum. Please zip your code files and attach them.
Regards,
Malini Selvarasu

Attachment: SfDataGrid_Demo_f00174da.zip


TD Tom Dennison March 19, 2025 02:34 PM UTC

Attached is my code file. I will look at the sample you provided. Thanks!



TD Tom Dennison March 19, 2025 02:39 PM UTC

I am not sure if the file uploaded so here it is again. 


Attachment: sfDataGrid_code.txt_4a24f778.zip


MS Malini Selvarasu Syncfusion Team March 20, 2025 07:39 AM UTC

Hi Tom Dennison,

Thank you for sharing your code file. We have reviewed it and attempted to replicate the issue, which was successfully reproduced.
Upon analyzing your code, we noticed that you have set HeaderRowHeight to zero and handled the QueryRowHeight event. Within this event, you check if the RowIndex is greater than zero and perform certain operations. However, you are directly setting e.Height to rowHeight, which also affects the HeaderRow.
To fix this issue, we recommend that you avoid setting the height for the HeaderRow within the QueryRowHeight event.
We have prepared a simplified sample with the modified code snippet. Please take a look at the code snippet and sample below, and let us know if it fixes your issue.
Code Snippet:
private void OnQueryRowHeight(object sender, QueryRowHeightEventArgs e)
{
    if (e.RowIndex > 0)
    {
        if ((this.RowCount - e.RowIndex) < 5 && _imageCollection != null)
        {
            _imageCollection.LoadNextBatchIfNeeded();
        }
    }
    if (e.RowIndex > 0)
    {
        e.Height = this.RowHeight;
        e.Handled = true;
    }
}

Thank you for your cooperation and understanding.

Regards,
Malini Selvarasu

Attachment: SfDataGrid_Demo_c36079b7.zip

Marked as answer

TD Tom Dennison March 20, 2025 02:16 PM UTC

Hi: removing the e.Height = thisRowheight did the trick. I was unaware that setting the row height would also impact the header, especially if I had set it to zero.  


Thank you for looking into this for me. 



MS Malini Selvarasu Syncfusion Team March 21, 2025 01:42 PM UTC

Hi Tom Dennison,

Thank you for your understanding. Please get back to us if you need any further assistance, we will be happy to help you.

Regards,
Malini Selvarasu

Loader.
Up arrow icon