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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Rich Text Box Backcolor

Thread ID:

Created:

Updated:

Platform:

Replies:

64343 Jul 18,2007 05:16 PM UTC Jul 23,2007 07:15 PM UTC WinForms 5
loading
Tags: GridControl
Burke Harris
Asked On July 18, 2007 05:16 PM UTC

I am having a problem with the rich text box. By default it seems to have a dark pruprle color if it made the current cell and activated. When it is in the current row but not current it has the desired AlphaBlendSelectionColor. The attached bitmap illustrates the issue.

I tried setting the cells style.Enabled = false in PrepareViewStyleInfo and that fixed the coloring issue but created other problems since having the cell disabled cancels downstream events that I need (CurrentCellMoving, CurrentCellActivating, etc.).

Is there some way to disable the the richtext control but still leave the cell as enabled?

ActiveCellIssue1.zip

Rajagopal [Syncfusion]
Replied On July 19, 2007 02:05 AM UTC

Hi Burke,

If you are looking to have the AlphaBlendSelectionColor for the current cell when the current cell is included in selections, then try the code below in the CellDrawn event and color it there instead of disabling the RichText cells.

private void grid_CellDrawn(object sender, Syncfusion.Windows.Forms.Grid.GridDrawCellEventArgs e)
{
GridCurrentCell cc = this.grid.CurrentCell;

if(e.ColIndex == cc.ColIndex && e.RowIndex == cc.RowIndex)
{
SolidBrush br = new SolidBrush(this.grid.AlphaBlendSelectionColor);
e.Graphics.FillRectangle(br, e.Bounds);
br.Dispose();
}
}

If you just want to change the backcolor of the active richtext cell, then use the below code in the PrepareViewStyleInfo event handler.
void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
if (e.RowIndex == cc.RowIndex && e.ColIndex == cc.ColIndex && e.Style.CellType == "RichText")
{
e.Style.BackColor = Color.Red;
}
}

Let me know if this helps.

Have a nice time.
Regards,
Rajagopal

Burke Harris
Replied On July 20, 2007 11:22 PM UTC

There seems to be a problem with the rich texts controls backcolor. When setting the backcolor (after binding), The control always renders darker than the desired color. No oter controls seem to have this issue. Please see code below.

//Set the column after binding.
GridBoundColumnsCollection gbcc = this.qDataBoundGrid1.Binder.InternalColumns;

gbcc[(int)GridColumns.strDIRECTPHONE - 1].StyleInfo.CellType = "RichText";
gbcc[(int)GridColumns.strDIRECTPHONE - 1].StyleInfo.BackColor = qDataBoundGrid1.AlphaBlendSelectionColor;

//Please See Attached screenshot
//Were AlphaBlendSelectionColor = 74, 51, 51, 102

RichTextIssue2.zip

haneefm [Syncfusion]
Replied On July 21, 2007 12:19 AM UTC

Hi Burke,

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;
}
}

Best regards,
Haneef

Burke Harris
Replied On July 23, 2007 03:47 PM UTC

The rich text cell is still rendering incorrectly (please see attachment). Any ideas why the cell backcolor would be different than the one specified in DrawCell?

private void QDataBoundGrid_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;

// AlphaBlendSelectionColor = (74,51,51,102)
Syncfusion.Drawing.RichTextPaint.DrawRichText(e.Graphics, s, false, rect, rect, this.AlphaBlendSelectionColor, rect, false, 100);
e.Cancel = true;
return;
}

}

RichTextIssue3.zip

Burke Harris
Replied On July 23, 2007 07:15 PM UTC

Found a fix.

Here is what I needed to fix the issue.

this.CellRenderers["RichText"].SupportsEditing = false;

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;