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

Row Height Auto Resize with TextWrap

I have noticed a weird behaviour when a user enters multiple lines of text in a cell that has been set-up to allow auto resize and text wrapping. On the first line, wrapping to the second, the cell height changes only very slightly, like 1px, the first line disappears upwards, and the second line is in the position of the first line. From the second to third, and subsequent lines, the cell height changes correctly, displaying the previous line, as well as creating a new line. Why is there a problem with just the first line? Thanks, Adrian.

3 Replies

AD Administrator Syncfusion Team February 20, 2003 07:35 AM

I think this is a bug that we will have to fix in our source. Here is a CurrentCellKeyPress event handler that you can try. Maybe it will give you better results than you are getting now.
private void gridControl1_CurrentCellKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
	GridCurrentCell cc = this.gridControl1.CurrentCell;
	GridStyleInfo style = this.gridControl1[cc.RowIndex, cc.ColIndex];
	if(style.AutoSize && style.WrapText)
	{
		this.gridControl1.BeginUpdate();
		cc.ConfirmChanges(false);
		GridRangeInfo range = GridRangeInfo.Cell(cc.RowIndex, cc.ColIndex);
		int nOldHeight = this.gridControl1.GetRowHeight(cc.RowIndex);
		this.gridControl1.RowHeights.ResizeToFit(range, GridResizeToFitOptions.NoShrinkSize|GridResizeToFitOptions.ResizeCoveredCells);
		this.gridControl1.EndUpdate();
		if(this.gridControl1.GetRowHeight(cc.RowIndex) != nOldHeight)
			this.gridControl1.Refresh();
	}
}


AL Adrian Launchbury February 20, 2003 10:28 PM

Ok that worked a bit better, but I noticed that for each progressively wrapped line, the cell height resizes earlier and earlier. As a specific example, it will change the row height three characters earlier than the actual end of the line on the fourth wrapped line. Also when using the enter key to wrap onto a new line (first time only), it still rolls the text up instead of onto a new line. Though it does seem to create a new spare empty line after entering the second character on the previous line (delayed?) Also the ConfirmChanges() function doesn’t take an argument, so how did you compile your example, do you have a different version? I am using version 1.5.1.1


AD Administrator Syncfusion Team February 21, 2003 04:09 AM

I am using the 1.5.1.6 public patch available from your support home page.

Loader.
Live Chat Icon For mobile
Up arrow icon