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
close icon

GGC: ResizeToFit Override Default RecordRowHeight

Hi there,

I have a GGC using the custom Syncfusion.GridHelperClasses.AllowResizingIndividualRows() engine to support resizing the individual row heights.

I've set its default row height to be 20. After setting its DataSource, I then call ResizeToFit so that all rows with multiline text are expanded vertically.
However, ResizeToFit seems to override the default row height to 22.

This is roughly my code (in sequence):


TableDescriptor.TableOptions.RecordRowHeight = TableOptions.RecordRowHeight = TableOptions.ColumnHeaderRowHeight = TableControl.DefaultRowHeight = 20;

// ... setting the grid DataSource ...

// After setting grid DataSource

TableControl.Model.RowHeights.ResizeToFit(GridRangeInfo.Table());

// After ResizeToFitabove, all my row heights with only one single line of text is no longer 20 but is now 22.
// Also TableDescriptor.TableOptions.RecordRowHeight is now 22.

Can you please point out on how to preserve the default row height (of row with single line of text) to be 20?


Thank you,

Magdalena

3 Replies

CI Christopher Issac Sunder K Syncfusion Team July 7, 2010 02:19 PM UTC

Hi Magdalena,

Thank you for your interest in Syncfusion products.

By default, the DefaultRecordRowHeight of a record is “18”. If we set DefaultRecordRowHeight manually and perform the ResizeToFit() operation, the single lined text record row will automatically override to “18”. To preserve the record row height of the single lined cell, you can handle the RowHeightsChanging event with the following code.


RowHeight = this.gridGroupingControl1.Table.DefaultRecordRowHeight;
this.gridGroupingControl1.DataSource = dt;
this.gridGroupingControl1.TableModel.RowHeightsChanging += new GridRowColSizeChangingEventHandler(TableModel_RowHeightsChanging);

void TableModel_RowHeightsChanging(object sender, GridRowColSizeChangingEventArgs e)
{
if (e.Values.Length > 1) // this avoid unwanted loopings.
{
for (int i = e.From; i < e.To; i++)
{
if (e.Values[i] == RowHeight)
{
e.Values[i] = 20; // set the rowheight here
}
}
}
}


Please refer the following sample which illustrates the above.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GCC_rowheight-151787830.zip

Please let me know if you have any other concerns.

Regards,
Christopher K.


JD JBS Developers July 9, 2010 02:56 AM UTC

Hello Christopher,

Thank you so much for your post update.
Your solution works, although I have to tweak it a bit to:

private void TableModel_RowHeightsChanging(object sender, GridRowColSizeChangingEventArgs e)
{
if (e.Values.Length > 0) // this avoid unwanted loopings.
{
for (int i = e.From; i <= e.To; i++)
{
if (e.Values[i] == 22)
{
e.Values[i] = 20; // set the rowheight here
}
}
}
}

I'm not sure why, but in my case after I do
TableModel.RowHeights.ResizeToFit(GridRangeInfo.Table(), GridResizeToFitOptions.ResizeCoveredCells);
All single line text gets resized to 22 (instead of 18 like your code sample).

Do you have any idea why?
I have no reference in my solution setting any row height to 22.

Thank you,

Magdalena


JJ Jisha Joy Syncfusion Team July 9, 2010 10:29 AM UTC

Hi Magdalena,

Thank you for your update. I have tested the issue in the following modified sample. It is working fine. Could you please provide us a sample that shows the issue or reproduce the issue in the attached sample?. So that we could sort out the cause of the issue and provide you a solution based on it.

Regards,
Jisha




I67330_24c5708f.zip

Loader.
Live Chat Icon For mobile
Up arrow icon