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

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

Thread ID:





120746 Oct 10,2015 09:23 PM UTC Oct 12,2015 12:25 PM UTC WinForms 1
Tags: GridControl
Asked On October 10, 2015 09:23 PM UTC


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?



Solai A L [Syncfusion]
Replied On 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 :



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

or the page will be automatically redirected to 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