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

Getting cell event to resize custom contents

Hi,

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.

Regards,
Russell

1 Reply

HA haneefm Syncfusion Team 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.
http://www.syncfusion.com/support/forums/message.aspx?&MessageID=60033

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,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon