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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Multi-Color in Cell

Thread ID:

Created:

Updated:

Platform:

Replies:

11377 Mar 4,2004 02:08 AM UTC Jun 8,2004 08:47 PM UTC Windows Forms 8
loading
Tags: GridControl
Satish
Asked On March 4, 2004 02:08 AM UTC

I would like to know how to change the color of the font in the cell. I have used to the cell type as richtextbox but still unable to chnage the color. I can able to change the size and font name of the text but not the color. Waiting for your reply. Thanks Satish

Administrator [Syncfusion]
Replied On March 4, 2004 06:06 AM UTC

To programmatically change the color of richtext in a cell, you could use code like:
private RichTextBox rtb = new RichTextBox();
		
private void button1_Click(object sender, System.EventArgs e)
{// cell 3,1 is richtext, code colors chars 3-6.
	rtb.Rtf = this.gridControl1[3,1].Text;
	rtb.SelectionStart = 2;
	rtb.SelectionLength = 4;
        rtb.SelectionColor = Color.Pink;
	this.gridControl1[3,1].Text = rtb.Rtf;
}
If you want to add the ability to change text color to the drop down panel that you get when you click the button in the richtext cell, then one way to do this is to derive GridRichTextEntryPanel, adding the toolbar item to implement color selection some how. You could use the code snippet above to actually affect the color change. Then you would derive GridRichTextBoxCellModel and GridRichTextBoxCellRenderer to make the cell control use your derived entry panel. All of the work would be in GridRichTextBoxCellRenderer where you would swap the code that uses the private panel member of that class so that in the derived class, the panel would be an instance of your derived panel.

Satish
Replied On March 5, 2004 04:29 AM UTC

Thanks for your help. Superb support. Can this be included in the next release (2.0) please. Thanks Satish >To programmatically change the color of richtext in a cell, you could use code like: >
>private RichTextBox rtb = new RichTextBox();
>		
>private void button1_Click(object sender, System.EventArgs e)
>{// cell 3,1 is richtext, code colors chars 3-6.
>	rtb.Rtf = this.gridControl1[3,1].Text;
>	rtb.SelectionStart = 2;
>	rtb.SelectionLength = 4;
>        rtb.SelectionColor = Color.Pink;
>	this.gridControl1[3,1].Text = rtb.Rtf;
>}
>
> >If you want to add the ability to change text color to the drop down panel that you get when you click the button in the richtext cell, then one way to do this is to derive GridRichTextEntryPanel, adding the toolbar item to implement color selection some how. You could use the code snippet above to actually affect the color change. > >Then you would derive GridRichTextBoxCellModel and GridRichTextBoxCellRenderer to make the cell control use your derived entry panel. All of the work would be in GridRichTextBoxCellRenderer where you would swap the code that uses the private panel member of that class so that in the derived class, the panel would be an instance of your derived panel.

Administrator [Syncfusion]
Replied On March 5, 2004 07:38 AM UTC

We do plan to add better support for RichText, but this cannot be done in the 2.0 release. It will be added in a later release.

Lori S. Pearsall
Replied On March 19, 2004 02:31 AM UTC

Could you expand on the info below? I''ve derived GridRichTextEntryPanel - how do I tell GridRichTextBoxCellRenderer to render my object rather than the standard one? > >Then you would derive GridRichTextBoxCellModel and GridRichTextBoxCellRenderer to make the cell control use your derived entry panel. All of the work would be in GridRichTextBoxCellRenderer where you would swap the code that uses the private panel member of that class so that in the derived class, the panel would be an instance of your derived panel.

Administrator [Syncfusion]
Replied On March 19, 2004 07:20 AM UTC

Below is a sample that shows how to get the renderer to use any UserControl as a dropdown (including one derived from GridRichTextEntryPanel). The idea is to override any method that the renderer baseclass uses to accesse the panel, and make sure you use your user control instead of letting the baseclass use its default GridRichTextEntryPanel. The problem I ran into was not getting the renderer to use the derived GridRichTextEntryPanel, but getting the derived GridRichTextEntryPanel working smoothly with its baseclass. It turned out easier for me to not derive from GridRichTextEntryPanel, but instead just derive from UserControl and add the functionality I wanted without trying to derive GridRichTextEntryPanel. It simply copies the code from GridRichTextEntryPanel to a new derived user control, and adds a button to the font tool bar that allows you to set the color on the selected text. When I tried to to this by deriving GridRichTextEntryPanel, the font toolbar was private and I could not access it to add the button. (This is what I meant when I said it was easier just to derived from UserControl and add things. GridRichTextEntryPanel was not designed for derivation in this respect.) forum11377_44.zip

Lori S. Pearsall
Replied On March 19, 2004 03:05 PM UTC

Many thanks!

Lori S. Pearsall
Replied On June 8, 2004 08:07 PM UTC

This may or may not pertain to the grid ... I''ve used your example and extended it for text & highlight color. It works great in my small test form using a GDBG. Now I''m in my regular project and I added this class in - no changes. The form appears in my grid but all the button images are missing. They display when I open up the class in design mode, but not when I''m running. Here''s the specifics of the parent form : It''s an MDI form using XPMenus & a ControlBar that hosts a child form containing a TabControlAdv that contains a GDBG using this richtext control. I''m thinking that I''m just missing something about the combination of these controls - any suggestions on where to start? Version 2.0.5.1

Administrator [Syncfusion]
Replied On June 8, 2004 08:47 PM UTC

Maybe the imagelist is not being loaded at runtime. If you check it at runtime, does it have the proper images in it?

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.

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

;