首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >XtraGrid:改变DetailButton风格

XtraGrid:改变DetailButton风格
EN

Stack Overflow用户
提问于 2015-08-18 13:56:46
回答 1查看 317关注 0票数 1

如何改变网格的细节按钮颜色和样式?突出显示在下面的图像。

如何在CustomDrawCell事件中以与XtraGrid完全相同的方式绘制主行的展开按钮。这不管用。

我们能添加我们自己的按钮/图像吗?或者有任何选项,我们可以添加另一个按钮与这个细节按钮?

编辑1:这里是代码。

代码语言:javascript
运行
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-08-19 06:33:10

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

下面是一个例子:

代码语言:javascript
运行
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32074500

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档