RichText in Virtual Grid Cell , get the underlying Renderer Control

Hi,

We are using Rich Text, to display rich text in each cell in the grid. We are not using custom renderer, but the built in rendering for rich text. We also have a click event registered for the grid. When the grid is clicked we would like to get the underlying richtext control associated with the cell, so that we can locate the string clicked on.

Is is possible to get the underlying richtext control associated with the cell? We need this since the mouse event for the click can get me the character and eventually the string clicked on.

If not how do I get the string clicked on in the cell that has richtext?

Thanks




2 Replies

SS Sean Sheldon October 17, 2007 01:59 AM UTC

We have strings separated by spaces.

>Hi,

We are using Rich Text, to display rich text in each cell in the grid. We are not using custom renderer, but the built in rendering for rich text. We also have a click event registered for the grid. When the grid is clicked we would like to get the underlying richtext control associated with the cell, so that we can locate the string clicked on.

Is is possible to get the underlying richtext control associated with the cell? We need this since the mouse event for the click can get me the character and eventually the string clicked on.

If not how do I get the string clicked on in the cell that has richtext?

Thanks





RA Rajagopal Syncfusion Team October 25, 2007 12:08 AM UTC

Hi,

To get access to the underlying richtext control in a cell you need to cast the clicked cell renderer as GridRichTextBoxCellRenderer and iterate through the Controls collection of the GridRichTextEntryPanel as in the below code.

GridCellRendererBase renderer = this.gridControl1.GetCellRenderer(row, col);
if (renderer is GridRichTextBoxCellRenderer)
{
GridRichTextBoxCellRenderer rtr = renderer as GridRichTextBoxCellRenderer;
foreach (Control c in rtr.DropDownContainer.Controls)
{
foreach (Control ct in (c as GridRichTextEntryPanel).Controls)
{
if (ct is RichTextBox)
{
RichTextBox rt = ct as RichTextBox;
}
}
}
}

You can get the string that is clicked on using the GetCharFromPosition() method of the RichTextBox. Please refer the below sample for more details on this.

Here is a sample
http://websamples.syncfusion.com/samples/Grid.Windows/F69160/main.htm

Let me know if you have any questions.

Thanks for using Syncfusion Products.

Regards,
Rajagopal

Loader.
Up arrow icon