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

Column ResizeToFit ComboBox Question

Thread ID:





59424 Apr 12,2007 01:28 PM UTC Apr 12,2007 06:50 PM UTC WinForms 2
Tags: GridControl
Kyle DeVoe
Asked On April 12, 2007 01:28 PM UTC

I have a question about using the column ResizeToFit() function. If if have a combobox in my column, the column will resize to the longest string in my combobox choicelist, even if that string isn't the selected item. How do I get the grid to ignore the choice list and only resize the column based on the display text in the combobox?


haneefm [Syncfusion]
Replied On April 12, 2007 06:09 PM UTC

Hi Kyle,

This can be acheived by deriving the GridComboBoxCellModel class and overriding OnQueryPrefferedClientSize Method to change the default resizing behavior of the combo box cell in a grid. Here is a code snippet to show this.

public class MyComboBoxCellModel : GridComboBoxCellModel
public MyComboBoxCellModel(GridModel grid): base(grid){}

protected override Size OnQueryPrefferedClientSize(Graphics g, int rowIndex, int colIndex, GridStyleInfo style, GridQueryBounds queryBounds)
Size size = g.MeasureString(style.FormattedText,style.GdipFont).ToSize();
return size + this.ButtonBarSize;
public override GridCellRendererBase CreateRenderer(GridControlBase control)
return new MyComboBoxCellRenderer(control, this);

Here is a sample.

Best Regards,

Kyle DeVoe
Replied On April 12, 2007 06:50 PM UTC


thank you for the example. This seems to be working well. Thanks for the quick reply.



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