Click here to Skip to main content
15,923,376 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

I want to format a single cell in DataGridView on some condition, i want to bold the font of that cell and some in italic,

how to do this?

if Any one knows please explain me.

thank you
Posted

1 solution

VB
Private Sub dgvClsJoin_CurrentCellDirtyStateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.CurrentCellDirtyStateChanged
       Try
           If (DataGridView1.IsCurrentCellDirty) Then
               DataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit)
                If DataGridView1.CurrentCell.Value <> 0 Then 'your condition
                                         If DataGridView1.CurrentCell.Value = 1 Then
                           DataGridView1.CurrentCell.Style.Font = New Font("Arial", 12, FontStyle.Bold)
                       End If
                  End If
           End If
       Catch
       End Try
   End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900