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

Regd---Justify Option in Richtextbox.

Hi There, Actually we want the fourth option Justify alignment apart from left,center,right alignments provided by Richtextbox.we have implemented it and succeded.The problem is I am using griddataboundgrid and one cell type is Richtext.If I set left,center,or right to the text in richtextbox even after losing the focus from the cell the text stays back in the selected alignment,where as if I set to Justify option , as soon as the cell looses the focus its not retaining justify option.May be this is the paint problem(OnDraw of GridRichTextboxcell of code).Please advice. Regards, Manohar.

1 Reply

AD Administrator Syncfusion Team September 28, 2005 12:15 PM UTC

Hi Manohar, it sounds as if the changes you made to the cell while it has focus were not saved into the cell. The proplem here is that GridDataBoundGrid only saves the cell value back as text and not the rich text codes into the underlying datasource. When the grid displays the rich text it uses the following code in its OnDraw method: rtf = style.Text; Rectangle clipBounds = GetCellBoundsCore(rowIndex, colIndex, true); Color backColor = Color.FromArgb(255, style.Interior.BackColor); RichTextPaint.DrawRichText(g, richTextBox, rtf, Grid.PrintingMode, Grid.GridBounds, textRectangle, clipBounds, backColor, style.WrapText, 100, Grid.IsRightToLeft()); So, in GridDataBoundGrid style.Text will only be the plain text (unless you store RTF in the datasource). What you would need to do this is format that text with RTF markup. Such formatting could be done in the QueryCellText event. Try subscribing to the event and modify the text cell contents there. Annother alternativ would be to handle the CellDraw event and call RichTextPaint.DrawRichText yourself. After drawing the cell contents set e.Handled = true. Stefan >Hi There, > > Actually we want the fourth option Justify alignment apart from left,center,right alignments provided by Richtextbox.we have implemented it and succeded.The problem is I am using griddataboundgrid and one cell type is Richtext.If I set left,center,or right to the text in richtextbox even after losing the focus from the cell the text stays back in the selected alignment,where as if I set to Justify option , as soon as the cell looses the focus its not retaining justify option.May be this is the paint problem(OnDraw of GridRichTextboxcell of code).Please advice. > >Regards, >Manohar. >

Loader.
Live Chat Icon For mobile
Up arrow icon