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

RichText Bug

Hi Please find the word document for more information. Thanks Satish DataGridBoundQuestions_5296.zip

9 Replies

AD Administrator Syncfusion Team April 13, 2004 03:29 PM UTC

The text you place in your RichText cells must be valid RichText. Otherwise, you will get the behavior you see. Here is a sample that does not show the problem for me. forumRTF_6736.zip


SA Satish April 14, 2004 12:54 AM UTC

Hi Clay, thanks for your reply. I am using derived RichText becuase i need to add the ''Paragraph indenting'' in the toolbar. Is this cause the problem? Thanks Satish >The text you place in your RichText cells must be valid RichText. Otherwise, you will get the behavior you see. Here is a sample that does not show the problem for me. >forumRTF_6736.zip > >


SA Satish April 14, 2004 03:25 AM UTC

Hi Clay, Thanks for your reply. I am using derived RichText box becuase I need to include ''Paragraph indenting'' icons and the functionaliy in the richtext box. Do you think any problems using derived RichText box? Thanks Satish >The text you place in your RichText cells must be valid RichText. Otherwise, you will get the behavior you see. Here is a sample that does not show the problem for me. >forumRTF_6736.zip > >


AD Administrator Syncfusion Team April 14, 2004 05:31 AM UTC

In the thread for your forum post, http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=11377, there is a sample posted that has a RichText cell with a Color selection added to the edit panel. I assume you should be able to do something similar to add parargraphing in some manner.


SA Satish April 14, 2004 06:41 AM UTC

Hi Clay, Again Thanks for your reply. Myy question is why this richtext box behaves differently. Please find the application for your reference. If you make changes in the one cell (I mean font, size and color change) which will be reflecting in other cells to. Why is this? Thanks Satish >In the thread for your forum post, http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=11377, there is a sample posted that has a RichText cell with a Color selection added to the edit panel. I assume you should be able to do something similar to add parargraphing in some manner. SampleApplication_2133.zip


SA Satish April 14, 2004 07:20 AM UTC

With regards to the above problem. In order to replicate this problem, try to move the move in the rows.......... Automatically rows values will get changed.. I mean font, Size, color........ >Hi Clay, >Again Thanks for your reply. >Myy question is why this richtext box behaves differently. Please find the application for your reference. >If you make changes in the one cell (I mean font, size and color change) which will be reflecting in other cells to. Why is this? >Thanks >Satish > >>In the thread for your forum post, http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=11377, there is a sample posted that has a RichText cell with a Color selection added to the edit panel. I assume you should be able to do something similar to add parargraphing in some manner. > >SampleApplication_2133.zip > >


AD Administrator Syncfusion Team April 14, 2004 07:23 AM UTC

The reason this is happening is as I tried to explain above. The text you are putting into the datatable is not RTF. It does not include the formatting information required of RTF. In your sample, if you replace dr[j] = string.Format("row{0} col{1}", i, j); with
if(j == 1)
{
	dr[j] =  @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}"
	+@"\viewkind4\uc1\pard\f0\fs17 "
	+ string.Format("row{0} col{1}", i, j)
	+@"\par }" ;
}
else
{
	dr[j] =  string.Format("row{0} col{1}", i, j);
}
you no longer see the problem as the datatable column will contain properly formatted RTF. Another option is to modify your cell renderer to automatically convert plain text into RTF text as it tries to draw the text (this may affect performance, but it is doable). To do so, you can add a private RichTextBox, and use it to change plain text in an override of OnDraw before calling the base class. Here is code that worked for me in your sample.
private RichTextBox rtb = new RichTextBox();
protected override void OnDraw(Graphics g, Rectangle clientRectangle, int rowIndex, int colIndex, GridStyleInfo style) 
{
	if (!(CurrentCell.HasCurrentCellAt(rowIndex, colIndex) && CurrentCell.IsModified && HasControlValue))
	{
		string rtf = style.Text;
		if (!RichTextPaint.IsValidRtf(rtf))
		{
			rtb.SelectAll();
			rtb.SelectedText = rtf;
			style.Text = rtb.Rtf;
		}
	}
	base.OnDraw(g, clientRectangle, rowIndex, colIndex, style);
}


SA Satish April 14, 2004 08:04 AM UTC

Great.. Its working... If this is the case, how do i convert my existing data into RTF. Is there any way???? Thanks Satish >The reason this is happening is as I tried to explain above. The text you are putting into the datatable is not RTF. It does not include the formatting information required of RTF. In your sample, if you replace > >dr[j] = string.Format("row{0} col{1}", i, j); > >with >
>if(j == 1)
>{
>	dr[j] =  @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}"
>	+@"\viewkind4\uc1\pard\f0\fs17 "
>	+ string.Format("row{0} col{1}", i, j)
>	+@"\par }" ;
>}
>else
>{
>	dr[j] =  string.Format("row{0} col{1}", i, j);
>}
>
>you no longer see the problem as the datatable column will contain properly formatted RTF. > >Another option is to modify your cell renderer to automatically convert plain text into RTF text as it tries to draw the text (this may affect performance, but it is doable). To do so, you can add a private RichTextBox, and use it to change plain text in an override of OnDraw before calling the base class. Here is code that worked for me in your sample. >
>private RichTextBox rtb = new RichTextBox();
>protected override void OnDraw(Graphics g, Rectangle clientRectangle, int rowIndex, int colIndex, GridStyleInfo style) 
>{
>	if (!(CurrentCell.HasCurrentCellAt(rowIndex, colIndex) && CurrentCell.IsModified && HasControlValue))
>	{
>		string rtf = style.Text;
>		if (!RichTextPaint.IsValidRtf(rtf))
>		{
>			rtb.SelectAll();
>			rtb.SelectedText = rtf;
>			style.Text = rtb.Rtf;
>		}
>	}
>	base.OnDraw(g, clientRectangle, rowIndex, colIndex, style);
>}
>


AD Administrator Syncfusion Team April 14, 2004 09:58 AM UTC

You would do it the same way as the OnDraw routine listed above does it. You would get your old string, set it in the SelectedText property of a RichTextBox, and then save the RTF property of the RichTextBox back to your database. Just like the code above.

Loader.
Live Chat Icon For mobile
Up arrow icon