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

GridControl cell RichText RowHeights and Rtf text

Hello,

I'm using GridControl with some RichText cells. First my problem was how to resize rows to fit the text. Then I found Thread 133539 so to solve the problem I start using CustomRichTextCell. This solve the problem in my regular grid.

Now I have another problem. In runtime I create a grid to change all the texts formats, colors and sizes to fit a A4 page before exporting to pdf. In this runtime grid RowHeights works fine but I can't change colors of letters in text since I use rtf format. I have inserted a RichTextBox with cell content and it shows the colors correctly.

Since Thread 133539 is from 2017 is there a better way to do RowHeights.ResizeToFit with GridCellTypeName.RichText cells?

About letters color in rtf is there a solution even using CustomRichTextCell?

Thanks


5 Replies 1 reply marked as answer

VS Vijayarasan Sivanandham Syncfusion Team January 19, 2023 02:43 PM UTC

Hi Dinis Ferreira,

We are analyzing your requirement of “GridControl cell RichText RowHeights and Rtf text" and update you with further details on Jan 23, 2023.

Regards,
Vijayarasan S



VS Vijayarasan Sivanandham Syncfusion Team January 23, 2023 05:02 PM UTC

 Dinis Ferreira,

We are still analyzing your requirement of “GridControl cell RichText RowHeights and Rtf text" and update you with further details on Jan 25, 2023.



VS Vijayarasan Sivanandham Syncfusion Team January 25, 2023 05:07 PM UTC

Dinis Ferreira,

Find the response to the queries,

Query

Response

 

Since Thread 133539 is from 2017 is there a better way to do RowHeights.ResizeToFit with GridCellTypeName.RichText cells?

 


We have investigated the possibility of resizing the cell content based on the rich text cell type loaded in GridControl. Unfortunately, there is no way to meet your requirement other than using the RowHeights.ResizeToFit method. For additional information on auto-sizing custom cells, please refer to the user guide documentation link provided below.

UG Link: https://help.syncfusion.com/windowsforms/grid-control/managing-the-rows-and-columns#auto-sizing-custom-cells

 

About letters color in rtf is there a solution even using CustomRichTextCell?

 


To change the color of the letters in a rich text cell of a GridControl, you can utilize the TextColor property and customize the QueryCellInfo event. Refer to the below code snippet,

//Way 1: Style the specific cell in GridControl

this.gridControl1.Model[1, 3].TextColor = Color.Green;

 

//Way 2: Style apply using QueryCellInfo event

this.gridControl1.QueryCellInfo += OnQueryCellInfo;

//Event customization

private void OnQueryCellInfo(object sender, GridQueryCellInfoEventArgs e)

{

    //Here customize based on your scenario

    if (e.Style.CellType == "RichTextCell" && e.RowIndex != 1)

    {

        //Here apply style based on your scenario

        e.Style.TextColor = Color.Red;

    }

}


UG Link: https://help.syncfusion.com/windowsforms/grid-control/cell-style-architecture#textcolor


KB Link: https://www.syncfusion.com/kb/453/how-to-edit-a-richtext-cell-in-gridcontrol


Find the sample in the attachment.


Regards,

Vijayarasan S


If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Attachment: GridControlDemo_b1d8e2bc.zip

Marked as answer

DF Dinis Ferreira January 30, 2023 02:22 PM UTC

This works.

Thanks



VS Vijayarasan Sivanandham Syncfusion Team January 31, 2023 03:47 AM UTC

Dinis Ferreira,

We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you😊.


Loader.
Up arrow icon