我需要更改 datagridview 中一行的颜色,但我的代码对我不起作用。我总是收到一条错误消息,提示“无法找到名为 Quantity 的列。参数名称:columnName”
这是我的代码:
Private Sub DataGridView1_CellFormatting(ByVal sender As Object, ByVal e As DataGridViewCellFormattingEventArgs) Handles DataGridView1.CellFormatting
For i As Integer = 0 To Me.DataGridView1.Rows.Count - 1
If Me.DataGridView1.Rows(i).Cells("Quantity:").Value < 5 Then
Me.DataGridView1.Rows(i).Cells("Quantity:").Style.ForeColor = Color.Red
End If
Next
End Sub
请帮我修复它。谢谢你。