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;
}
}
};
}
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:
|
|
|
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. |
Regards,
Malini Selvarasu
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.
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
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?
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.
- 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.
Malini Selvarasu
Attachment: SfDataGrid_Demo_f00174da.zip
Attached is my code file. I will look at the sample you provided. Thanks!
I am not sure if the file uploaded so here it is again.
Attachment: sfDataGrid_code.txt_4a24f778.zip
Thank you for sharing your code file. We have reviewed it and attempted to replicate the issue, which was successfully reproduced.
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
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.
Thank you for your understanding. Please get back to us if you need any further assistance, we will be happy to help you.
- 10 Replies
- 2 Participants
- Marked answer
-
TD Tom Dennison
- Mar 14, 2025 06:25 PM UTC
- Mar 21, 2025 01:42 PM UTC