Search code examples
c#vb.netwinformsinfragistics

Is there a way to change the background of a single cell in ultragrid?


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#


Solution

  • 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