我在官方网站和多个论坛上看过,但它改变了整行或列的背景色。下面是我想要实现的一些伪代码:
If cellValue != 0 or cellValue Isnot nothing
change background color of cellValue to yellow
你知道怎么做吗?我很感谢任何帮助,最好是在vb.net或c#
If e.Row.Cells("CELL_NAME").Text <> 0 Then
e.Row.Appearance.BackColor = Color.Red 'change row's color
e.Row.Cells("CELL_NAME").Appearance.BackColor = Color.Red 'change cell's color
End If
此代码用于InitializeRows事件。您在此事件中编写的代码将在网格的所有行上执行。
在Marco的帮助下找到了解决方案。我的目标是在特定列的值不为0时更改其单元格颜色。顺便说一句,您需要在initizerow事件中执行此操作。我是这样做的:
For Each column As UltraGridColumn In ugResult.DisplayLayout.Bands(0).Columns
If column.ToString = "K_Art" Or column.ToString = "UANR" Or column.ToString = "Ueberbegriff" Or column.ToString = "Benennung" Or column.ToString = "Anzahl" Or column.ToString = "Einheit" Or column.ToString = "Einzelkosten" Or column.ToString = "Sumcode" Or column.ToString = "Status" Then
Exit For
Else
For Each r As UltraGridRow In ugResult.Rows
If r.Cells(column.Index).Value <> 0 Then
r.Cells(column.Index).Appearance.BackColor = Color.Yellow
End If
Next
End If
Next