XtraGrid:更改 DetailButton 样式

XtraGrid: Change DetailButton style

如何更改Grid 的Detail 按钮的颜色和样式?在下图中突出显示。

How to paint the master row's expand buttons within the CustomDrawCell event in exactly the same manner as the XtraGrid does。这不起作用。

我们可以添加自己的 button/image 吗?或者是否有任何选项可以让我们在这个详细信息按钮旁边添加另一个按钮?

编辑 1: 这是代码。

Private Sub GridView1_CustomDrawCell(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs) Handles GridView1.CustomDrawCell

    Dim cell As GridCellInfo = CType(e.Cell, GridCellInfo)

    Dim view As GridView = CType(sender, GridView)

    Dim p As ObjectPainter = cell.RowInfo.ViewInfo.Painter.ElementsPainter.DetailButton

    If Not cell.CellButtonRect.IsEmpty Then

        ObjectPainter.DrawObject(e.Cache, p, _

            New DevExpress.XtraGrid.Drawing.DetailButtonObjectInfoArgs( _

                cell.CellButtonRect, view.GetMasterRowExpanded(cell.RowHandle), cell.RowInfo.IsMasterRowEmpty))

    End If

    ...

    e.Handled = True

End Sub

您可以使用 GridView.CustomDrawCell 事件。只需将 GridCellInfo.CellButtonRect 属性 设置为 Rectangle.Empty,使用 e.DefaultDraw() 方法执行单元格的默认绘制,恢复 GridCellInfo.CellButtonRect 属性 的值并之后绘制图像。
这是示例:

Private Sub gridView1_CustomDrawCell(sender As Object, e As RowCellCustomDrawEventArgs) Handles gridView1.CustomDrawCell

    Dim info = CType(e.Cell, GridCellInfo)

    If Not info.CellButtonRect.IsEmpty Then
        Dim detailRect = info.CellButtonRect

        info.CellButtonRect = Rectangle.Empty

        e.DefaultDraw()

        info.CellButtonRect = detailRect

        e.Graphics.DrawImageUnscaled(yourImageHere, detailRect.X, detailRect.Y)

        e.Handled = True
    End If

End Sub