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.

Resize to fit is not working when cell type is "RichText"

Thread ID:

Created:

Updated:

Platform:

Replies:

102562 Feb 9,2012 08:58 AM Feb 15,2012 07:36 AM Windows Forms 1
loading
Tags: GridControl
venkatesh
Asked On February 9, 2012 08:58 AM

Some how i am not able to respond to my previous post. "i am not getting Post Update Button to post me response". so i am creating a new post.

My first concern is i have to resize the row height on load but not on user action.

and the resize to fit is not working when cell type is "RichText" . i am able to resize height if cell type is "not Richtext".

Below is my question and answer given by Ragamathulla

venkatesh at 2/8/2012 10:59:00 AM

I am using Grid which is extended from "Winforms Syncfusion GridDataBoundGrid" and gird contains one column(cells) which is of type Richtext. So each and every row height will be different depending on the content of the Rich text cell.
I need to re-size the row depending on that content. i am able to increase the height of the row if the cell is not rich text using following code


i am using following code to resize row height...

_currentGrid.Model.RowHeights.ResizeToFit(GridRangeInfo.Table(), GridResizeToFitOptions.NoShrinkSize);

This is working when there is now cell of type RichText.. if i change a cell to RichText then above code is not resizing row height.

Ragamathulla B[Syncfusion] at 2/9/2012 7:31:53 AM
Hi Venkatesh,

Thank you for your interest in syncfusion products

You can resize the RowHeight when the current cell as accept the change by using ‘CurrentCellAcceptedChanges’ event. The following code explains the same.

void grid_CurrentCellAcceptedChanges(object sender, CancelEventArgs e)
{
this.grid.Model.RowHeights.ResizeToFit(GridRangeInfo.Cell(this.grid.CurrentCell.RowIndex, this.grid.CurrentCell.ColIndex));
}


Hope this will be helpful for your references.

http://help.syncfusion.com/ug_94/User%20Interface/Windows%20Forms/Grid/Documents/414148resizetofit.htm

Please refer to the following sample which illustrates the same


Kalaiarasan B [Syncfusion]
Replied On February 15, 2012 07:36 AM

Hi Venkatesh,

Thank you for your interest in Syncfusion products.

If your need is to resize the rows to Fit based on their size of its contents even whileloading the form, you can use the same ResizeToFit function in RowHeights of the model by passing the entire table or specific rows in GridRangeInfo as an argument, in the constructor of the form itself.

Please refer the code below

this.gridDataBoundGrid2.Model.RowHeights.ResizeToFit(GridRangeInfo.Table(),GridResizeToFitOptions.None) // Resize all the rows in the table

this.gridDataBoundGrid2.Model.RowHeights.ResizeToFit(GridRangeInfo.Rows(top,bottom),GridResizeToFitOptions.None) // top, bottom - range of rows


If the ResizeToFit doesn't works in resizing based on the contents,then you can assign the rowheights by calculating the values manually and assign to the rows.

Please make use of the code

SizeF stringSize;
Graphics grapics = CreateGraphics();
long maxHeight = 0;
GridStyleInfo style = this.grid.GetViewStyleInfo(e.Rows.Bottom, 1);
stringSize = grapics.MeasureString(style.Text, style.GdipFont,this.grid.Model.ColWidths[1]);
if (maxHeight < stringSize.Height)
{
maxHeight = (long)stringSize.Height;
}
this.grid.Model.RowHeights[e.Rows.Bottom] = (int)maxHeight;


Please let me know if you have any other concerns.

Regards,
Kalai



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.

;