【问题标题】:dev express xtra grid removes stylingdevexpress xtragrid 移除样式
【发布时间】:2018-01-25 13:53:45
【问题描述】:

我有一个 XtraGrid 类型的传入电子邮件网格。 我有一个名为“isRead”的列,它是布尔类型的。

 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

这就是为我传入的电子邮件样式处理我的网格的原因。 乍一看,我的代码可以正常工作,无论何时加载我的表单,我的样式都是正确的。

一旦我在我的网格内单击,所有粗体项目都会恢复正常!! 似乎它做了某种刷新。 没有监听点击事件的事件。

为什么会这样? 您还有什么建议吗?

【问题讨论】:

  • 如果不了解其他XtraGrid 设置的更多详细信息,就很难重现该问题。您确定所有网格事件处理程序都设置正确(包括RowClick)吗?

标签: vb.net devexpress xtragrid


【解决方案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

【讨论】:

  • 我如何调用这个子?我尝试:gridvwIncEmailsList_RowStyle(gridvwIncEmailsList, e) 我收到以下错误:“:'无法将'System.EventArgs'类型的对象转换为'DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs'。'”
  • 如此处所述:documentation.devexpress.com/WindowsForms/… 在重新绘制单个数据或组行之前引发 RowStyle 事件。数据行和组行的外观设置分别由 GridViewAppearances.Row 和 GridViewAppearances.GroupRow 属性指定。处理此事件以覆盖各个行的外观设置。
  • '无法将'System.EventArgs'类型的对象转换为'DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs'。'
  • 你的答案几乎是正确的,只要解决这三件事。 1. "Private Sub gridvwIncEmailsList_RowStyle(ByVal sender As Object, ByVal e As RowStyleEventArgs) Handles gridvwIncEmailsList.RowStyle" 2. Dim IsRead As String = View.GetRowCellDisplayText(e.RowHandle, View.Columns("IsRead")) 3.If IsRead =“未选中”然后
  • 好收获。更新了!
猜你喜欢
  • 1970-01-01
  • 2017-01-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多