Free Support Forum -

GridWeb Cell BackColor

I have multiple rows in a grid. Depending on data I need for certain cells in the row to have a darker cell color. The cells with the background color will be different on each row. I have tried using

Dim sheet As WebWorksheet = grdInput.WebWorksheets(grdInput.ActiveSheetIndex)

Dim cell As WebCell

cell = sheet.Cells(rowCount, 11)

cell.Style.BackColor = Drawing.Color.SteelBlue

When I use this code, it changes the color on all alternating cells in column 11. However, I need for only the one cell in the column to change. What am I doing wrong here?




Well, normally your code works fine. If you have implemented databinding. Well, in databinding mode, all the cells in a column will share one style object. If you want set a unique style for a particular cell in sheet in databinding mode, you should create a standalone style object for that cell.


After you call the sheet.DataBind() method, you may add the following lines of code:

’ Binding.
Dim cell1 As WebCell = sheet.Cells(rowCount, 11)
’ create a new style object
Dim style1 As New Aspose.Cells.GridWeb.TableItemStyle()
’ copy from the cell’s style
style1.BackColor = Color.SteelBlue
cell1.Style = style1

If you still find any issue, kindly create a sample project to show the issue, we will check it soon.

Thank you.