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

GDBG: RichText...

Hi,
1) Is there an easy way to disable arrow in each cell ('RichText' type) of GridDataBoundGrid control?

2) On which event i should use Syncfusion.Drawing.RichTextPaint.DrawRichText(...)? I'd like to use this method to make the rich text not wrapable.

3) Which property of GDBG i should use to get richTextControl, which is hosted in a cell and which i should put as argument in DrawRichText(...)?

13 Replies

AL Alex June 26, 2007 02:44 PM UTC

In 1) i mean not to disable but HIDE an arrow.


HA haneefm Syncfusion Team June 26, 2007 02:47 PM UTC

Hi Alex,

1) Is there an easy way to disable arrow in each cell ('RichText' type) of GridDataBoundGrid control?
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
You can hide dropdown(arrow) button by setting the style.ShowButtons property for the cells to GridShowButtons.Hide. Below is a code snippet

GridStyleInfo style = this.grid.Binder.InternalColumns["RichTextColumn"].StyleInfo;
style.ShowButtons = GridShowButtons.Hide;

2) On which event i should use Syncfusion.Drawing.RichTextPaint.DrawRichText(...)? I'd like to use this method to make the rich text not wrapable.
And
3) Which property of GDBG i should use to get richTextControl, which is hosted in a cell and which i should put as argument in DrawRichText(...)?
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
You can do is to handle the DrawDisplayText event and draw the text yourself in a way that works with the WrapText using the DrawRichText static method.

[c#]
Syncfusion.Drawing.RichTextPaint.DrawRichText(e.Graphics, rtb, rtf, this.gridControl1.PrintingMode , Bounds1, e.TextRectangle, Bounds2, e.Style.BackColor, false, 100, false);

Here is a forum thread that discuss with the DrawRichText method.
http://www.syncfusion.com/forums/message.asp?MessageID=35231

Best regards,
Haneef


AL Alex June 26, 2007 02:55 PM UTC

Thank you for quick answer but this link

http://www.syncfusion.com/forums/message.asp?MessageID=35231

is not working for me. It loads the main forum page.
?


HA haneefm Syncfusion Team June 26, 2007 03:08 PM UTC



AL Alex June 26, 2007 03:34 PM UTC

Ok, thanks but you've said:
"You can do is to handle the DrawDisplayText event and draw the text yourself in a way that works with the WrapText using the DrawRichText static method."


Do you mean the event DrawCellDisplayText of GDBG ? (Which class DrawDisplayText-event is belong to? I cant find it.)

Should i use DrawCellDisplayText(...) with RichTextBox as second argument, or another overloaded version without it?

Article is said:
"Annother alternativ would be to handle the CellDraw event and call RichTextPaint.DrawRichText yourself. After drawing the cell contents set e.Handled = true.
"
CellDraw? or CellDrawn? But as i can see this event has arguments which is not suitable for drawing with help of DrawRichText.






AL Alex June 26, 2007 06:44 PM UTC

Hello again,

I've tried DrawRichText method, but more's the pity it ignores wrapping.

Is there any way to access GridRichTextEntryPanel. It got the public property 'RichTextBox'.
All i need is to set property of ReachTextBox.WorldWrap to false.


AL Alex June 26, 2007 09:40 PM UTC

Hello, I've made a good example to demonstrate the problem. I hope it will help you to help me.

=)

I long for your answer.


WindowsApplication249.zip


AL Alex June 26, 2007 10:02 PM UTC

Sorry, ive made a mistake in comment to file UsualRichTextBox.cs. In question "So the question is how to achieve the appearence of usual RichTextBox which property WordWrap set to true ?" i mean "WordWrap set to false".


HA haneefm Syncfusion Team June 26, 2007 10:21 PM UTC

Hi Alex,

You can access the GridRichTextBoxCellRenderer from CellRenderers collection property and set the WordWrap property false in a RichTextBox. Below is a code snippet

GridRichTextBoxCellRenderer cr = (GridRichTextBoxCellRenderer)this.gridDataBoundGrid1.CellRenderers["RichText"];
if (cr != null)
{
GridRichTextEntryPanel b = cr.DropDownContainer.Controls[0] as GridRichTextEntryPanel;
RichTextBox r = b.Controls[1] as RichTextBox;
r.WordWrap = false;
}

Modified sample : ModifiedWindowsApplication249.zip

Best regards,
Haneef


AL Alex June 26, 2007 10:35 PM UTC

Wow, well done!
Thank you very much, Haneef.
I've spent many hours to do it. And already have a headache about this problem =).
It was very important thing to be done...

Great support, Haneef!


AL Alex June 26, 2007 11:24 PM UTC

Hmm, sorry, but im a little bit tired. And ive taken your modified example for the right thing.
But the problem is that CellType = "Static" in the example and i need it in a "RichText", because i need font formatting in a cell.
So if we comment '#define STATIC' - we'll see the wrong behavor: text is wrapping in spite of "r.WordWrap = false". Is it a bug or something?

Anyway, thank you for your help.


AL Alex June 27, 2007 08:40 AM UTC

Haneef,
would you please give me the working example of using
RichTextPaint.DrawRichText(...); ?
In the example the strings shouldn't be wrapped and a piece of string should have any font formatting.


HA haneefm Syncfusion Team June 27, 2007 11:48 PM UTC

Hi Alex,

There is no property setting that will do this for you. but here is one way.

You can use the DrawCellEvent, and draw this cell yourself. In your code, you would need to check for Richtext type for the cell, and draw the cell if there are RichText type. Here is a try at this.

void gridDataBoundGrid1_DrawCell(object sender, GridDrawCellEventArgs e)
{
if (e.Style.CellType == "RichText")
{
string s = e.Style.Text;
e.Style.Text = "";
e.Renderer.Draw(e.Graphics, e.Bounds, e.RowIndex, e.ColIndex, e.Style);
Rectangle rect = e.Bounds;
rect.Width = this.gridDataBoundGrid1.Width;
RichTextPaint.DrawRichText(e.Graphics, s, false, rect, rect, Color.Pink, rect, false, 100);
e.Cancel = true;
}
}

Please refer to the attached sample for implementation.
ModifiedRichTextBoxApplication.zip

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon