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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridControl Column autofit to the size of its cell value

Thread ID:





109847 Jul 8,2013 09:52 AM UTC Jul 12,2013 08:41 AM UTC WinForms 1
Tags: GridControl
Pallavi Sagapuram
Asked On July 8, 2013 09:52 AM UTC

I want to set the column of grid control to get autosized based on the cell value. The column is of type Combobox.

i have tried this but still no use

Model.ColWidths.ResizeToFit(this.GridCellsRange, GridResizeToFitOptions.IncludeHeaders);

Arun Kumar V [Syncfusion]
Replied On July 12, 2013 08:41 AM UTC

Hi Pallavi,
Thanks for your interst in Syncfusion products.
To Reset the column width based on the cellvalue resizetofit method will work. Could you please let me know the exact essential studio version you are using.
You can also make use of the following method.
private void customizeWidth()
 Size stringSize;int temp = 0;
 for (int col = 0; col <= this.gridGroupingControl1.TableModel.ColCount; col++)
  for (int row = 0; row <= this.gridGroupingControl1.TableModel.RowCount; row++)
    stringSize = TextRenderer.MeasureText(this.gridGroupingControl1.TableModel[row,col].Text, Font);
             if (stringSize.Width > temp)
               temp = stringSize.Width;
             if (row == this.gridGroupingControl1.TableModel.RowCount)
                this.gridGroupingControl1.TableModel.ColWidths[col] = temp + 15;
                temp = 0;
please let me know if you have any concerns.


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon