dev express xtra网格删除样式

时间:2018-01-25 13:53:45

标签: vb.net devexpress xtragrid

我有一个传入的电子邮件网格,类型为XtraGrid。 我有一个名为" isRead"它的类型为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

这就是我的网格对待我传入的电子邮件风格。 乍一看我的代码是有效的,无论何时我的表单加载我的样式都是正确的。

一旦我点击我的网格内所有粗体项目恢复正常! 好像它做了某种刷新。 没有事件可以监听点击事件。

为什么会这样? 你还有其他建议吗?

1 个答案:

答案 0 :(得分:1)

尝试XtraGrid的RowStyle事件: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