我的目標是為與我已經著色的完全相同的單元格著色,但之前只有一列。我試過用索引來做,但沒有成功。我得到一個提示,我應該用 Key 屬性來做,但我不知道如何做。這是我嘗試過的:
For Each column As UltraGridColumn In ugResult.DisplayLayout.Bands(0).Columns
If column.Key = "K_Art" Or column.Key = "UANR" Or column.Key = "Ueberbegriff" Or column.Key = "Benennung" Or column.Key = "Anzahl" Or column.Key = "Einheit" Or column.Key = "Einzelkosten" Or column.Key = "Sumcode" Or column.Key = "Status" Then
Exit For
Else
If e.Row.Cells(column.Key).Value IsNot Nothing Then
e.Row.Cells(column.Key).Appearance.BackColor = Color.Yellow
e.Row.Cells(column.Index - 1).Appearance.BackColor = Color.Yellow
End If
End If
Next
感謝在 c# 和 vb.net 中的任何幫助。謝謝
uj5u.com熱心網友回復:
我認為這會奏效:
For Each column As UltraGridColumn In ugResult.DisplayLayout.Bands(0).Columns
If column.Key = "K_Art" Or column.Key = "UANR" Or column.Key = "Ueberbegriff" Or column.Key = "Benennung" Or column.Key = "Anzahl" Or column.Key = "Einheit" Or column.Key = "Einzelkosten" Or column.Key = "Sumcode" Or column.Key = "Status" Then
Exit For
Else
If e.Row.Cells(column.Key).Value IsNot Nothing Then
e.Row.Cells(column.Index).Appearance.BackColor = Color.Yellow
e.Row.Cells(column.Index - 1).Appearance.BackColor = Color.Yellow
End If
End If
Next
uj5u.com熱心網友回復:
您應該DbNull.Value像這樣比較單元格的值:
For Each column As UltraGridColumn In ugResult.DisplayLayout.Bands(0).Columns
If column.Key = "K_Art" Or column.Key = "UANR" Or column.Key = "Ueberbegriff" Or column.Key = "Benennung" Or column.Key = "Anzahl" Or column.Key = "Einheit" Or column.Key = "Einzelkosten" Or column.Key = "Sumcode" Or column.Key = "Status" Then
Exit For
Else
If Not DbNull.Value.Equals(e.Row.Cells(column.Key).Value) Then
e.Row.Cells(column.Key).Appearance.BackColor = Color.Yellow
e.Row.Cells(column.Index - 1).Appearance.BackColor = Color.Yellow
End If
End If
Next
uj5u.com熱心網友回復:
這是我的解決方案:
For Each column As UltraGridColumn In ugResult.DisplayLayout.Bands(0).Columns
Select Case column.Key
Case "K_ArtCompare"
If e.Row.Cells(column.Key).Value IsNot Nothing Then
e.Row.Cells(column.Key).Appearance.BackColor = Color.Yellow
e.Row.Cells("K_Art").Appearance.BackColor = Color.Yellow
Else
e.Row.Cells(column.Key).Value = e.Row.Cells("K_Art").Value
End If
Case "UANR_Compare"
If e.Row.Cells(column.Key).Value IsNot Nothing Then
e.Row.Cells(column.Key).Appearance.BackColor = Color.Yellow
e.Row.Cells("UANR").Appearance.BackColor = Color.Yellow
Else
e.Row.Cells(column.Key).Value = e.Row.Cells("UANR").Value
End If
Case "UeberbegriffCompare"
If e.Row.Cells(column.Key).Value IsNot Nothing Then
e.Row.Cells(column.Key).Appearance.BackColor = Color.Yellow
e.Row.Cells("Ueberbegriff").Appearance.BackColor = Color.Yellow
Else
e.Row.Cells(column.Key).Value = e.Row.Cells("Ueberbegriff").Value
End If
Case "BenennungCompare"
If e.Row.Cells(column.Key).Value IsNot Nothing Then
e.Row.Cells(column.Key).Appearance.BackColor = Color.Yellow
e.Row.Cells("Benennung").Appearance.BackColor = Color.Yellow
Else
e.Row.Cells(column.Key).Value = e.Row.Cells("Benennung").Value
End If
Case "AnzahlCompare"
If e.Row.Cells(column.Key).Value <> -1 Then
e.Row.Cells(column.Key).Appearance.BackColor = Color.Yellow
e.Row.Cells("Anzahl").Appearance.BackColor = Color.Yellow
Else
e.Row.Cells(column.Key).Value = e.Row.Cells("Anzahl").Value
End If
Case "EinheitCompare"
If e.Row.Cells(column.Key).Value IsNot Nothing Then
e.Row.Cells(column.Key).Appearance.BackColor = Color.Yellow
e.Row.Cells("Einheit").Appearance.BackColor = Color.Yellow
End If
Case "EinzelkostenCompare"
If e.Row.Cells(column.Key).Value <> -1 Then
e.Row.Cells(column.Key).Appearance.BackColor = Color.Yellow
e.Row.Cells("Einzelkosten").Appearance.BackColor = Color.Yellow
Else
e.Row.Cells(column.Key).Value = e.Row.Cells("Einzelkosten").Value
End If
Case "SummencodeCompare"
If e.Row.Cells(column.Key).Value IsNot Nothing Then
e.Row.Cells(column.Key).Appearance.BackColor = Color.Yellow
e.Row.Cells("Sumcode").Appearance.BackColor = Color.Yellow
Else
e.Row.Cells(column.Key).Value = e.Row.Cells("Sumcode").Value
End If
End Select
Next
End Select
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/349314.html
下一篇:查看Json請求
