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

Column header height in GGC

Hi, when I change font size in my grid, I have problems with column height that does not auto-adjust when I do : GGC.Appearance.ColumnHeaderCell.AutoSize = True. I tried to find alternatively to adjust the Column Header height manually, but it seems this property is not available. Am I doing something wrong? Thank you in advance! - Nicolas

7 Replies

NK Neelakandan Kannan Syncfusion Team August 16, 2016 04:37 AM UTC

Hi Nicolas, 

Thanks for your interest in Syncfusion products. 

The column header row height or column width can be resized based on its font style and size by using the ResizeToFit method. Please make use of below code, 

Code snippet 
//To resize the column header's width 
this.gridGroupingControl1.TableModel.ColWidths.ResizeToFit(GridRangeInfo.Row(this.gridGroupingControl1.TableControl.TopRowIndex - 1), GridResizeToFitOptions.IncludeHeaders); 
 
//To resize the column header's row height.  
this.gridGroupingControl1.TableModel.RowHeights.ResizeToFit(GridRangeInfo.Row(this.gridGroupingControl1.TableControl.TopRowIndex - 1), GridResizeToFitOptions.IncludeHeaders); 

Regards, 
Neelakandan 
 



NI Nicolas August 16, 2016 02:36 PM UTC

Hi! Thank you for the prompt answer on this! I tried the codes, and it worked well using GridRangeInfo.Table(), but failed to achieve to resize either Column header height or width using GridRangeInfo.Row(this.gridGroupingControl1.TableControl.TopRowIndex - 1). As I do not want necessarily to resize the complete table, could you propose an alternative to the proposed GridRangeInfo? Thank you in advance! - Nicolas


NK Neelakandan Kannan Syncfusion Team August 17, 2016 10:29 AM UTC

Hi Paul, 

Sorry for the inconvenience caused. 

Query  
Solution Feedback 


As per screenshots, we understood that the you don’t want to set the selection backcolor by hardcode and the selection backcolor should be taken from the backcolor of the row. As per this case, we had provided the solution as ListBoxSelectionColorOptions  =  GridListBoxSelectionColorOptions.None.  
 
We have provided the information about all the options available in the Selections in the below UG link, 
 
We have provided information about customization and workarounds in the below Knowledge Base, 
 
We will ensure that this kind of miscommunication won’t happen anymore in the future. Thanks for your understanding. 


Query 
How can I detect the the cell style info event QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e) being on a "selected row"?  


The row can be checked if it is selected or not by the using the GetRecord().IsSelected() method. Please make use of the below code, 

this.gridGroupingControl1.QueryCellStyleInfo += new  
GridTableCellStyleInfoEventHandler(gridGroupingControl1_QueryCellStyleInfo); 
 
void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e) 
{ 
if (e.TableCellIdentity != null && (e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell  
    || e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell) && 
    e.TableCellIdentity.DisplayElement.GetRecord().IsSelected()) 
    e.Style.BackColor = Color.Red; 

 
Regards, 
Neelakandan 
 



NI Nicolas August 17, 2016 05:07 PM UTC

Hi Neelakandan, I believe you are in the wrong topic here - Nicolas


MG Mohanraj Gunasekaran Syncfusion Team August 18, 2016 04:11 PM UTC

Hi Nicolas, 
 
Sorry for the inconvenience caused, 
 
We have analyzed your query at our end. You can achieve your requirement by using the Element.GetRowIndex method. Please refer the following code snippet. 
 
Code snippet: 
foreach (Element el in this.gridGroupingControl1.Table.NestedDisplayElements) 
{ 
    if (el.Kind == Syncfusion.Grouping.DisplayElementKind.ColumnHeader) 
    { 
        rowIndex=el.GetRowIndex(); 
        break; 
    } 
} 
if (rowIndex >= 0) 
{ 
    //To resize the column header's width  
    this.gridGroupingControl1.TableModel.ColWidths.ResizeToFit(GridRangeInfo.Row(rowIndex), GridResizeToFitOptions.IncludeHeaders); 
 
    //To resize the row height's width  
    this.gridGroupingControl1.TableModel.RowHeights.ResizeToFit(GridRangeInfo.Row(rowIndex), GridResizeToFitOptions.IncludeHeaders); 
} 
 
Regards, 
Mohanraj G.  



NI Nicolas August 23, 2016 01:10 AM UTC

Hi, I have tried both solutions using the event, this, in order to resize column header row height upon resize by the end-user :

Private Sub TableModel_QueryColWidth(sender As Object, e As GridRowColSizeEventArgs)

Apparently, both solutions get into an infinite loop on the form opening. It is not an important feature at the moment, just a "nice-to-have", maybe the team could think of integrating a dedicated property for this one in a future deployment. My side, I consider the case as closed, but let me know if there is any development, thanks to the team - Nicolas



AR Amal Raj U Syncfusion Team August 23, 2016 11:35 AM UTC

Hi Nicolas, 

Thanks for the update. 

As per the current support provided in the GridGroupingControl, there is no support to get the row index of the column header section without using loop. As per our previous update, the loop will not be executed for infinite times as we break the loop once the column section is found. So the loop will execute maximum of 2 to 3 times only. Please let us know if we missed anything.  

If you are facing infinite loop for the given solution, could you please send us the sample with issue reproducing, so that we can find out the cause of issue and provide you the solution at the earliest? 

Regards, 
Amal Raj U. 


Loader.
Up arrow icon