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

AutoSize ComboBox in GridControl to match largest width in DataSource or ChoiceList


I have some ComboBox cells in a GridControl. They each have a DataSource which specifies the items to show when the ComboBox is expanded.

I want to autosize the ComboBox so that it will fit the width of the largest item within its DataSource instead of autosizing to fit its current value.

I have been using the code below to do the autosize, but as I said before it only looks at the current value in the ComboBox cell to determine the width instead of looking in its DataSource or ChoiceList. Is there any way to get it to autosize as per the largest width entry in the DataSource?



1 Reply

SA Solai A L Syncfusion Team October 12, 2015 12:25 PM UTC

Hi Taylour,

Thank you for your interest in Syncfusion products.

We can change the size of combo box drop down as per the size of the text using the QueryCellInfo event. Please refer to the following code and sample.
Code :

  void gridControl1_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)


            if (e.RowIndex > 0 && e.ColIndex > 0 && e.Style.CellType ==GridCellTypeName.ComboBox)


                var m = items[0];

                for (int i = 0; i < items.Count; i++)


                    if (Convert.ToDouble(m) > Convert.ToDouble(items[i]))

                        m = items[i];


                gridControl1.ColWidths[e.ColIndex] = TextRenderer.MeasureText(m.ToString(),new System.Drawing.Font(gridControl1[2, 3].Font.Facename, gridControl1[2, 3].Font.Size)).Width;



Sample :


Live Chat Icon For mobile
Up arrow icon