I've looked on the offical infragistics site and in multiple forums but either it changes the backcolor of the whole row or of the column. Here some pseudocode of what i want to achieve:
If cellValue != 0 or cellValue Isnot nothing
change background color of cellValue to yellow
Do you have an idea how to do that? I appreciate any help, prefered in vb.net or c#
CodePudding user response:
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
This Code works on InitializeRows Event. The code you write in this event is executed on all lines of the grid.
CodePudding user response:
Found out the solution with the help of Marco. My goal was to change the cell Color in specific columns if their value isn't 0. You need to do this in the InitalizeRow Event btw. Here's what I did:
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