c# - 使用 columns 键和为每个更改超网格中的单元格颜色
问题描述
我的目标是为我已经着色的完全相同的单元格着色,但之前只有一列。我试着用索引来做,但没有成功。我得到一个提示,我应该用 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 的任何帮助表示赞赏。谢谢
解决方案
这是我的解决方案:
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
推荐阅读
- javascript - Vue.js - 通过过滤器设置背景图像的最佳方法
- jquery - 为什么即使屏幕具有相同的分辨率,CSS 媒体查询看起来也不一样
- json - Angular 6 - 从本地加载 JSON
- c# - 使用硬件键盘更改变量时在 Xamarin Forms 中处理事件
- javascript - 为什么我收到“无法读取未定义的‘值’?
- kotlin - 使用 LinearStateQueryCriteria 时,如何获取按修改顺序排序的查询输出
- java - Spring Data Containing 不适用于 Integer
- azure - Azure 函数构建未生成 function.json
- uwp - 是否可以设置密度 Bar inc UWP CalendarView 的高度
- stanford-nlp - 斯坦福 CoreNLP 在其他语言上的执行时间