vendredi 9 juillet 2021

How to set DataGridView1 Rows FontStyle with condition GridView Load Time. using VB.net

how to Check all rows of dataGridView and set FontStyle with conditions.

the my Condition is if Cell Value Equal 0 then Strikeout otherwise Regular

    Private Function DetailGridViewSetStyle()
    Dim dgv As DataGridView = DetailDataGridView
    Dim dgvInd As Integer = dgv.CurrentRow.Index
   
    For cc As Integer = 0 To dgv.ColumnCount - 1

        If dgv.Item(4, dgvInd).Value = 0 Then

            dgv.DefaultCellStyle.Font = New Font("ARIAL", 8, FontStyle.Strikeout)

        ElseIf dgv.Item(4, dgvInd).Value = 1 Then

            dgv.DefaultCellStyle.Font = New Font("ARIAL", 8, FontStyle.Regular)
        End If

    Next
End Function

Aucun commentaire:

Enregistrer un commentaire