ReoGrid
ReoGrid copied to clipboard
Cells[].Style.TextColor problem
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.

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