vb.netdevexpressxtragrid

dev express xtra grid removes styling


I have an incoming emails grid which is of type XtraGrid. I have a column called "isRead" which is of type boolean.

 Private Sub IsReadEmails_BoldFont()
    'This Sub checks all data and if their column "IsRead" is equal to 0 then will make all this rows font Bold.
    Dim IsRead As Boolean

    For i As Integer = 0 To gridvwIncEmailsList.RowCount
        IsRead = gridvwIncEmailsList.GetRowCellValue(i, gridvwIncEmailsList.Columns(13))
        If Not (IsRead) Then
            gridvwIncEmailsList.SelectRow(i)
            gridvwIncEmailsList.Appearance.SelectedRow.BackColor = Color.White
            gridvwIncEmailsList.Appearance.SelectedRow.Font = New Font("Tahoma", 10.0F, FontStyle.Bold)
            gridvwIncEmailsList.Appearance.SelectedRow.ForeColor = Color.Black

        End If
    Next

End Sub

This is what treats my grid for my incoming emaisl style. At a first glance my code works, WHenever my form loads my styling is correct.

Once i click inside my grid all bold items are restored to normal!! Seems like it does some kind of refresh. There are no events that listen to the click event.

Why is this happening? Do you have any more suggestions?


Solution

  • Try the RowStyle event for the XtraGrid: DevExpress Custom Grid Styles

        Private Sub gridvwIncEmailsList_RowStyle(ByVal sender As Object,
             ByVal e As RowStyleEventArgs) Handles gridvwIncEmailsList.RowStyle
        Dim View As GridView = TryCast(sender, GridView)
        If e.RowHandle >= 0 Then
            Dim IsRead As String = View.GetRowCellDisplayText(e.RowHandle, View.Columns("IsRead"))
           If IsRead = "Unchecked" Then
                e.Appearance.BackColor = Color.FromArgb(150, Color.LightCoral)
                e.Appearance.BackColor2 = Color.White
                e.Appearance.BackColor = Color.White
               e.Appearance.Font = New Font("Tahoma", 10.0F, FontStyle.Bold)
                e.Appearance.ForeColor = Color.Black
            End If
        End If
    End Sub