ReoGrid icon indicating copy to clipboard operation
ReoGrid copied to clipboard

Cells[].Style.TextColor problem

Open DerekG007 opened this issue 5 years ago • 2 comments

Library: unvell.ReoGrid Version 2.2.0.0 Platform: WPF

Problem I'm using the ReoGrid as a datagrid editor and trying to perform some form of data validation. I'm trying to change the color of the cell to RED/WHITE of the current row and affected row.

The BackColor works, the background color of all the cells change to red for the allocated rows. The TextColor only changes the color of the text in the cell that is being edited. TextColor

Am I doing the TextColor assignment correctly, or is there a possible problem in the underlying code ?

Code

 searchBell = currentSheet.Cells[callRowNo, 1].DisplayText + currentSheet.Cells[callRowNo, 2].DisplayText +
                         currentSheet.Cells[callRowNo, 3].DisplayText + currentSheet.Cells[callRowNo, 4].DisplayText;

 if (bellNo == searchBell)
                    {
                        for (int iCol = 1; iCol < 5; iCol++)
                        {
                            currentSheet.Cells[iRowNo,    iCol].Style.BackColor    = unvell.ReoGrid.Graphics.SolidColor.Red;
                            currentSheet.Cells[iRowNo,    iCol].Style.TextColor    = unvell.ReoGrid.Graphics.SolidColor.White;                            
                            currentSheet.Cells[callRowNo, iCol].Style.BackColor    = unvell.ReoGrid.Graphics.SolidColor.Red;                           
                            currentSheet.Cells[callRowNo, iCol].Style.TextColor    = unvell.ReoGrid.Graphics.SolidColor.White;
                        }                        
                        return true;
                    }
                    else
                    {
                        for (int iCol = 1; iCol < 5; iCol++)
                        {
                            currentSheet.Cells[iRowNo,    iCol].Style.BackColor    = unvell.ReoGrid.Graphics.SolidColor.Transparent;
                            currentSheet.Cells[iRowNo,    iCol].Style.TextColor    = unvell.ReoGrid.Graphics.SolidColor.Black;
                            currentSheet.Cells[callRowNo, iCol].Style.BackColor    = unvell.ReoGrid.Graphics.SolidColor.Transparent;
                            currentSheet.Cells[callRowNo, iCol].Style.TextColor    = unvell.ReoGrid.Graphics.SolidColor.Black;
                        }
                    }
                }

DerekG007 avatar Oct 02 '20 08:10 DerekG007

i prefer use

RangePosition range = new RangePosition(e.CellPosition.Row, 0, 1, e.Worksheet.Columns);

GridData.CurrentWorksheet.SetRangeStyles(range, new WorksheetRangeStyle
{
    Flag = PlainStyleFlag.TextColor,
    BackColor = Color.LightYellow,
});

var range = new RangePosition(0, 0, 1, MaxCol);

worksheet.SetRangeStyles(0, 0, 1, MaxCol, new WorksheetRangeStyle
{
    Flag = PlainStyleFlag.FontSize | PlainStyleFlag.BackColor | PlainStyleFlag.HorizontalAlign | PlainStyleFlag.VerticalAlign,
    FontSize = 10,
    BackColor = Color.SkyBlue,
    HAlign = ReoGridHorAlign.Center,
    VAlign = ReoGridVerAlign.Middle
});

worksheet.SetRangeBorders(range, BorderPositions.All, new RangeBorderStyle { 
    Color = System.Drawing.Color.Black, Style = BorderLineStyle.BoldSolid });

liusaiweng avatar Oct 09 '20 15:10 liusaiweng

I see the same issue while using the following code:

 _worksheet.SetRangeStyles(colRange, new WorksheetRangeStyle()
                {
                    Flag = PlainStyleFlag.FontSize |
                    PlainStyleFlag.FontName |
                    PlainStyleFlag.FontStyleBold |
                    PlainStyleFlag.TextWrap |
                    PlainStyleFlag.TextColor,

                    TextColor = SolidColor.Red,
                    TextWrapMode = TextWrapMode.WordBreak,
                    FontName = "Calibri",
                    FontSize = 12,
                    Bold = col.IsBold,
                });

All is set correctly and only textColor stays the same, if editing the cell the color is RED after the editing

jhonson27 avatar Feb 15 '21 16:02 jhonson27