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

How auto size columns

Thread ID:

Created:

Updated:

Platform:

Replies:

132127 Aug 15,2017 03:39 PM Aug 18,2017 02:45 AM Windows Forms 3
loading
Tags: GridGroupingControl
Ricardo Esteban Veloz Granados
Asked On August 15, 2017 03:39 PM

Hi, some body know, how autosize columns, to show all cell content without change the row height

Arulpriya Ramalingam [Syncfusion]
Replied On August 16, 2017 06:11 AM

Hi Ricardo,   
  
Thanks for using Syncfusion products.   
  
Suggestion 1   
  
In order to resize the column width based on length of the cell value, the AutoSize property of GridStyleInfo can be set to true and the WrapText property of GridStyleInfo can be set to flase. Please make use of below code and sample,   
  
Code example:  
   
   
//To resize the column based on length of cell value   
this.gridGroupingControl1.AllowProportionalColumnSizing = false;   
this.gridGroupingControl1.TableDescriptor.Appearance.AnyRecordFieldCell.AutoSize = true;   
this.gridGroupingControl1.TableDescriptor.Appearance.AnyRecordFieldCell.WrapText = false;    
   
   
   
Suggestion 2   
   
The QueryCellStyleInfo event can also be used to resize the column width based on length of the cell value. In that event, the AutoSize and WrapText properties can be used. Please refer to the below code,   
  
Code example  
   
   
this.gridGroupingControl1.QueryCellStyleInfo += GridGroupingControl1_QueryCellStyleInfo;   
private void GridGroupingControl1_QueryCellStyleInfo(object sender,GridTableCellStyleInfoEventArgs e)   
{   
    e.Style.AutoSize = true;   
    e.Style.WrapText = false;   
}   
   
   
   
Suggestion 3   
   
The ResizeToFit() method of GridModelRowColIndexer can also be used to resize the column width based on length of the cell value. Please refer to the below code,   
  
Code example   
   
   
//To resize the column based on length of cell value   
this.gridGroupingControl1.TableModel.ColWidths.ResizeToFit(GridRangeInfo.Table());   
   
   
   
Note   
The AllowProportionalColumnSizing property should be set to false  
   
  
Regards,   
Arulpriya   


Ricardo Esteban Veloz Granados
Replied On August 17, 2017 01:35 PM

Thanks, its help me and is the solution to what I was looking for, only one cuestion more


Through designer is possible to change this property ?

this.gridGroupingControl1.AllowProportionalColumnSizing = false;



Arulpriya Ramalingam [Syncfusion]
Replied On August 18, 2017 02:45 AM

Hi Ricardo,   
   
Thanks for your update.   
   
We could understand your scenario. We regret to let you know that the GridGroupingControl does not have support for setting theAllowProportionalColumnSizing in designer. As we updated earlier, the AllowProportionalColumnSizing can be set programmatically. Please make use of below UG link,   
   
   
Please let us know if you have any other queries.   
   
Regards,   
Arulpriya  


CONFIRMATION

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.

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.

;