我有一个CellFormatting
子对于我编写的代码无法正常工作,因为它包含一个循环(它干扰了UI)。摆脱循环修复了问题,但我不能锻炼如何消除它同时保持我的方程。这是代码 WITH 循环
For k = 8 To 52 Step 2
If row.Cells(k).Value Is DBNull.Value Or row.Cells(k).Value Is Nothing Then Continue For
Dim firstDate As Date = DirectCast(row.Cells(k).Value, Date)
Dim N As Date = Now
Dim diff As TimeSpan = N - firstDate
If diff.Days > 14 AndAlso row.Cells(k + 1).Value = 0 Then
row.Cells(k - 1).Value = 6
ElseIf diff.Days > 14 AndAlso row.Cells(k + 1).Value <> 0 Then
row.Cells(k - 1).Value = row.Cells(k - 3).Value
End If
Next k
这是代码 WITHOUT 我试图用它替换它的循环。我已将[{1}}替换为修复了UI问题的k
,但代码实际上并没有对e.columnIndex
DataGridView
如何编写上面的代码块(保持循环)并使其与此问题中的第一个代码块一样工作?
提前致谢