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.
Unfortunately, activation email could not send to your email. Please try again.

Getting cell event to resize custom contents

Thread ID:

Created:

Updated:

Platform:

Replies:

60375 May 3,2007 01:07 PM May 3,2007 02:11 PM Windows Forms 1
loading
Tags: GridControl
Russell Coombes
Asked On May 3, 2007 01:07 PM

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

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

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

CONFIRMATION

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.

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.

;