Rich Text in Grid Control Cell
Hi,
I am trying to display some rich text in cell of a grid control, but it always displays the contents with all the formatting characters. I have set the cell type to RichText. I have also implemented the GridPrepareViewStyle, to get the cell back color and cell text color. The default text color is black, but the contents of the cell should display the rich text in a different color, for which I have the rich text format characters.
Is there something else that I need to do.
Please help.
this.mainGrid[0, iCol].Text = "Classification";
this.mainGrid.ColStyles[iCol].HorizontalAlignment = GridHorizontalAlignment.Left;
this.mainGrid.ColWidths[iCol] = 150;
this.mainGrid.ColStyles[iCol].Tag = iCol;
this.mainGrid.ColStyles[iCol].CellType = "RichText";
I am trying to display some rich text in cell of a grid control, but it always displays the contents with all the formatting characters. I have set the cell type to RichText. I have also implemented the GridPrepareViewStyle, to get the cell back color and cell text color. The default text color is black, but the contents of the cell should display the rich text in a different color, for which I have the rich text format characters.
Is there something else that I need to do.
Please help.
this.mainGrid[0, iCol].Text = "Classification";
this.mainGrid.ColStyles[iCol].HorizontalAlignment = GridHorizontalAlignment.Left;
this.mainGrid.ColWidths[iCol] = 150;
this.mainGrid.ColStyles[iCol].Tag = iCol;
this.mainGrid.ColStyles[iCol].CellType = "RichText";
SIGN IN To post a reply.
3 Replies
HA
haneefm
Syncfusion Team
February 4, 2008 11:11 PM UTC
Hi Deepak,
The RichText sample illustrates how you can display and edit RichText in the Grid Cells. It will allow you to optionally dropdown an editable RichText window where you can modify the RichText in the cell. In addition, this sample will allow you to display an event log which, will show the order of the currentcell events that are raised and the values that are present in the cell as the events occur. You will be able to see mouse events as well.
Here is a path.
C:\Documents and Settings\haneefm\My Documents\Syncfusion\EssentialStudio\5.2.0.30\Windows\Grid.Windows\Samples\2.0\CellTypes\RichTextCells\cs
Best regards,
Haneef
The RichText sample illustrates how you can display and edit RichText in the Grid Cells. It will allow you to optionally dropdown an editable RichText window where you can modify the RichText in the cell. In addition, this sample will allow you to display an event log which, will show the order of the currentcell events that are raised and the values that are present in the cell as the events occur. You will be able to see mouse events as well.
Here is a path.
C:\Documents and Settings\haneefm\My Documents\Syncfusion\EssentialStudio\5.2.0.30\Windows\Grid.Windows\Samples\2.0\CellTypes\RichTextCells\cs
Best regards,
Haneef
DE
Deepak
February 5, 2008 11:09 PM UTC
I had a look at the sample code, I am doing something similar but I still see problems with my Rich text box.
I have pasted some sample code below
void GridPrepareViewStyle(object sender, GridPrepareViewStyleInfoEventArgs e)
{
try
{
if (e.RowIndex > 0 && e.ColIndex > 0)
{
int iCol = Convert.ToInt32(this.mainGrid.ColStyles[e.ColIndex].Tag);
if (this.displayData.Count < e.RowIndex) return;
GridData val = (GridData)this.displayData[e.RowIndex-1];
if(val!=null )
{
e.Style.TextColor = val.GetCellTextColorByIndex(iCol);
e.Style.BackColor = val.GetCellBackColorByIndex(e.RowIndex, iCol);
}
val = null;
}
}
catch (Exception er)
{
Console.WriteLine("GridPrepareViewStyle Error: " + er.Message);
}
}
This the string that has to be displayed
string sHighlightRTF = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
{\colortbl ;\red255\green0\blue0;}
{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\cf1\f0\fs20 !\cf0\par
}";
sample.zip
I have pasted some sample code below
void GridPrepareViewStyle(object sender, GridPrepareViewStyleInfoEventArgs e)
{
try
{
if (e.RowIndex > 0 && e.ColIndex > 0)
{
int iCol = Convert.ToInt32(this.mainGrid.ColStyles[e.ColIndex].Tag);
if (this.displayData.Count < e.RowIndex) return;
GridData val = (GridData)this.displayData[e.RowIndex-1];
if(val!=null )
{
e.Style.TextColor = val.GetCellTextColorByIndex(iCol);
e.Style.BackColor = val.GetCellBackColorByIndex(e.RowIndex, iCol);
}
val = null;
}
}
catch (Exception er)
{
Console.WriteLine("GridPrepareViewStyle Error: " + er.Message);
}
}
This the string that has to be displayed
string sHighlightRTF = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
{\colortbl ;\red255\green0\blue0;}
{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\cf1\f0\fs20 !\cf0\par
}";
sample.zip
JS
Jeba S
Syncfusion Team
February 9, 2008 09:28 AM UTC
Hi Deepak,
Thank you for your details.
I have looked into the code provided by you.
Do you have more than one grid? The below code snippets indicates there are two grids in your application.
Could you please provide some more details to reproduce the issue? Or modify the below browser sample to reproduce the issue so that we can provide you a solution early?
{Installation Drive}\Documents and Settings\{Username}\My Documents\Syncfusion\EssentialStudio\6.1.034\Windows\Grid.Windows\Samples\2.0\CellTypes\RichTextCells
Kindly let us know if you need any further assistance.
Best Regards,
Jeba.
Thank you for your details.
I have looked into the code provided by you.
Do you have more than one grid? The below code snippets indicates there are two grids in your application.
this.mainGrid.ColStyles[e.ColIndex].Tag
this.displayData.Count
Could you please provide some more details to reproduce the issue? Or modify the below browser sample to reproduce the issue so that we can provide you a solution early?
{Installation Drive}\Documents and Settings\{Username}\My Documents\Syncfusion\EssentialStudio\6.1.034\Windows\Grid.Windows\Samples\2.0\CellTypes\RichTextCells
Kindly let us know if you need any further assistance.
Best Regards,
Jeba.
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
-
DE Deepak
- Feb 4, 2008 08:57 PM UTC
- Feb 9, 2008 09:28 AM UTC