【发布时间】:2016-09-01 04:29:30
【问题描述】:
我有一个这样的列表视图:
它显示项目描述和交付数量。
- 如果所有数量都交付了,我需要用绿色显示线。
- 如果有任何数量交付(部分)然后,我需要显示为橙色。
- 如果当时没有发货,我需要显示黄色。
我给出了这样的代码,但它不起作用。
ListView1.Font = New System.Drawing.Font("Tahoma", 8.0!, System.Drawing.FontStyle.Bold)
ListView1.Items.Clear()
If ds.Tables(0).Rows.Count > 0 Then
Dim dt As DataTable = ds.Tables(0)
Dim str(ds.Tables(0).Columns.Count) As String
Dim lvi As ListViewItem
Dim rr As DataRow
Dim highlight As String = ""
Dim temp1 As String = ""
Dim temp2 As String = ""
Dim temp1Sum, temp2Sum As Integer
Dim diffCount As Integer = 0
Dim newColumn As Integer = 0
Dim strTemp As String
For Each rr In dt.Rows
For col As Integer = 0 To ds.Tables(0).Columns.Count - 1
str(col) = rr(col).ToString()
If col > 4 And col > newColumn Then
Dim qtyVal As String
qtyVal = rr(col).ToString
strTemp = qtyVal
If temp1 = "" Then
temp1 = IIf(qtyVal = "", "0.00", qtyVal)
Else
temp2 = temp1
temp1 = IIf(qtyVal = "", "0.00", qtyVal)
newColumn = col + 1
End If
If temp1 <> "" And temp2 <> "" Then
If temp1 <> temp2 Then
diffCount = diffCount + 1
End If
temp1 = ""
temp2 = ""
End If
End If
Next
lvi = New ListViewItem(str)
ListView1.Items.Add(lvi)
If diffCount = 0 Then
lvi.BackColor = Color.Green
noofdeliver = noofdeliver + 1
txtdelivercount.Text = noofdeliver
ElseIf diffCount > 0 Then
If temp2Sum = 0 Then
lvi.BackColor = Color.Yellow
Else
lvi.BackColor = Color.Orange
End If
End If
temp2Sum = 0
diffCount = 0
newColumn = 0
Next
End If
【问题讨论】:
-
有什么更新吗?任何人都可以提供任何帮助