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

displaying/editing with embedded tabs in databoundgrid

I''m evaluating essential grid for a data project I''m working on. One problem I''ve found, occurs when text in the database contains embedded tab characters. After the data is loaded into the grid, i run the .Model.RowHeights.ResizeToFit process on the grid. When the text is presented in the grid, each tab takes a single space, however when you click in the cell to edit it, the tabs expand to read correctly. Is there a way to set the grid so it shows the tabs expanded at display time as well as during cell edit? Thanks Jim Frisby

4 Replies

AD Administrator Syncfusion Team June 30, 2004 04:18 PM UTC

There is no property setting to handle this. One thing you can do is to handle the DrawDisplayText event and draw the text yourself in a way that shows the tabs. For example, you can draw it as Richtext.
private RichTextBox rtb = new RichTextBox();
private void gridDataBoundGrid1_DrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
{
	if(e.Style.CellIdentity.ColIndex == 2) //use for column 2
	{
		rtb.Clear();
		rtb.SelectedText = e.DisplayText;
		string rtf = rtb.Rtf;
		Syncfusion.Drawing.RichTextPaint.DrawRichText(e.Graphics, rtb, rtf, this.gridDataBoundGrid1.PrintingMode, this.gridDataBoundGrid1.GridBounds, e.TextRectangle, 
this.gridDataBoundGrid1.GridBounds, e.Style.BackColor, e.Style.WrapText, 100, false);
		e.Cancel = true;
	}
}
Depending upon the version of the grid you are using, the DrawRichText method shown above may give a syntax error. If so, try removing the last argument.


JA James A Frisby(For EPS - Computer Software) June 30, 2004 06:18 PM UTC

Clay, Your suggestion makes the tabs show correctly, but curiously, since I''m using "Model.RowHeights.ResizeToFit", it now formats the height such that the last line of the text doesn''t show anymore. Jim >There is no property setting to handle this. > >One thing you can do is to handle the DrawDisplayText event and draw the text yourself in a way that shows the tabs. For example, you can draw it as Richtext. > >
>private RichTextBox rtb = new RichTextBox();
>private void gridDataBoundGrid1_DrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
>{
>	if(e.Style.CellIdentity.ColIndex == 2) //use for column 2
>	{
>		rtb.Clear();
>		rtb.SelectedText = e.DisplayText;
>		string rtf = rtb.Rtf;
>		Syncfusion.Drawing.RichTextPaint.DrawRichText(e.Graphics, rtb, rtf, this.gridDataBoundGrid1.PrintingMode, this.gridDataBoundGrid1.GridBounds, e.TextRectangle, 
>this.gridDataBoundGrid1.GridBounds, e.Style.BackColor, e.Style.WrapText, 100, false);
>		e.Cancel = true;
>	}
>}
>
> >Depending upon the version of the grid you are using, the DrawRichText method shown above may give a syntax error. If so, try removing the last argument.


AD Administrator Syncfusion Team June 30, 2004 07:38 PM UTC

I do not have a simple solution for this problem. The sizing algorithm is using the same strings as the orignal problem you described, and thus, does not use the tab in the string.


JA James A Frisby(For EPS - Computer Software) July 1, 2004 04:04 PM UTC

Ok, thanks

Loader.
Live Chat Icon For mobile
Up arrow icon