簡體   English   中英

如果行/列單元為空,則突出顯示datagridview行(vb.net)

[英]highlight datagridview row if row/column cell is empty (vb.net)

我有一個datagridview,如果該單元格中沒有任何值,則突出顯示自身,目前僅適用於一個單元格,我想再添加2個單元格,因此,如果3個單元格中沒有任何值,則突出顯示行。

目前的代碼:

Private Sub DataGridView1_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs) Handles DataGridView1.CellFormatting

    For i As Integer = 1 To Me.DataGridView1.Rows.Count - 1
        If Me.DataGridView1.Rows(i).Cells("DateFixed1").Value = ("") Then
            Me.DataGridView1.Rows(i).Cells("DateFixed1").Style.ForeColor = Color.Black
            Me.DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.PaleVioletRed
        End If
    Next

End Sub
For Each row As GridViewRow In Me.DataGridView1.Rows
        For Each cell As DataGridViewCell In row.cells
            If cell.Value = ("") 
            Then
               cell.Style.ForeColor = Color.Black
               row.DefaultCellStyle.BackColor = Color.PaleVioletRed
            End If
        Next
Next

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM