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);
>}
>