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.

GridControl Column autofit to the size of its cell value

Thread ID:

Created:

Updated:

Platform:

Replies:

109847 Jul 8,2013 05:52 AM Jul 12,2013 04:41 AM Windows Forms 1
loading
Tags: GridControl
Pallavi Sagapuram
Asked On July 8, 2013 05:52 AM

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 04:41 AM

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.
Regards,
Arun.

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.

;