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

Getting cell event to resize custom contents

Thread ID:





60375 May 3,2007 05:07 PM UTC May 3,2007 06:11 PM UTC WinForms 1
Tags: GridControl
Russell Coombes
Asked On May 3, 2007 05:07 PM UTC


Does anyone know of an event that fires when an cell has been databound?

I think I need to capture this event, so I can fire some sort of 'RefitSizeToFit' method on the cell, so that it fits neatly around the custom control that it contains. I have tried to set the 'AutoSize' to true on the appearance of AnyRecordFieldCell but it does not work.


haneefm [Syncfusion]
Replied On May 3, 2007 06:11 PM UTC

Hi Russell,

Regarding CustomControl:

You can try handling the QueryCellStyleInfo event. But calling the ReSizeToFit method in the QueryCellStyleInfo event makes the recursive call. So you can set the ColWidth of the cell by using the CalculatePreferredCellSize method. Here is a code snippet.

private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
if( e.TableCellIdentity.Column != null)
GridGroupingControl grid = sender as GridGroupingControl;
using( Graphics grp = grid.CreateGraphics())
//For getting the Right ColWidth...
Size size = e.Style.CellModel.CalculatePreferredCellSize(grp,e.TableCellIdentity.RowIndex,e.TableCellIdentity.ColIndex,e.Style,GridQueryBounds.Width);
//For getting the Right RowHeight...
///Size size = e.Style.CellModel.CalculatePreferredCellSize(grp,e.TableCellIdentity.RowIndex,e.TableCellIdentity.ColIndex,e.Style,GridQueryBounds.Height);
if( e.TableCellIdentity.Column.Width < size.Width)
e.TableCellIdentity.Column.Width = size.Width;

Setting the individualized rowheights in a GridGroupingControl, see this.

Regarding Autosize property:
If you set AutoSize property to Truw, the cell height should automatically increase when the edited text does not fit into the cell and WrapText is True. If WrapText is False, AutoSize will affect the column width.

Best regards,


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