How auto size columns
Hi, some body know, how autosize columns, to show all cell content without change the row height
SIGN IN To post a reply.
3 Replies
AR
Arulpriya Ramalingam
Syncfusion Team
August 16, 2017 10:11 AM UTC
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
RE
Ricardo Esteban Veloz Granados
August 17, 2017 05:35 PM UTC
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;
AR
Arulpriya Ramalingam
Syncfusion Team
August 18, 2017 06:45 AM UTC
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,
UG link: https://help.syncfusion.com/windowsforms/grid/managing-the-rows-and-columns#proportional-sizing
Please let us know if you have any other queries.
Regards,
Arulpriya
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
RE Ricardo Esteban Veloz Granados
- Aug 15, 2017 07:39 PM UTC
- Aug 18, 2017 06:45 AM UTC