BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
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); }
>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); >} >