markdown 在重点行的DevExpress红色边界

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 在重点行的DevExpress红色边界相关的知识,希望对你有一定的参考价值。

Red Border on Focused Row

This involves the Paint event of the GridControl which for some reason is not exposed so you need to add an event handler when you initalize the form/user control.

    Public Sub New()
        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        gvEstimates.FocusRectStyle = DrawFocusRectStyle.RowFocus
        AddHandler gcEstimates.Paint, AddressOf gcEstimates_Paint
    End Sub
    
Then in the Paint event add this code:

    Private Sub gcEstimates_Paint(ByVal sender As Object, ByVal e As PaintEventArgs)
        Dim grid As GridControl = TryCast(sender, GridControl)
        Dim view As GridView = TryCast(grid.FocusedView, GridView)
        Dim viewInfo As GridViewInfo = TryCast(view.GetViewInfo(), GridViewInfo)
        Dim rowInfo As GridRowInfo = viewInfo.GetGridRowInfo(view.FocusedRowHandle)
        If rowInfo Is Nothing Then Return
        Dim r As Rectangle = Rectangle.Empty
        r = rowInfo.Bounds
        If r <> Rectangle.Empty Then
            r.Height -= 2
            r.Width -= 2
            e.Graphics.DrawRectangle(Pens.Red, r)
        End If
    End Sub

To make the border wider, use a wider pen. You also have to invalidate the grid control to force a redraw. It seems to work best if you invalidate the grid control in the grid view's FocusedRowChanged event.

    ....
    e.Graphics.DrawRectangle(New Pen(Color.Red, 2), r)
    ....
    
    Private Sub MyGridView_FocusedRowChanged(sender As Object, e As Views.Base.FocusedRowChangedEventArgs) Handles gvEstimates.FocusedRowChanged
        Me.MyGridControl.Invalidate()
    End Sub
    
    
    

以上是关于markdown 在重点行的DevExpress红色边界的主要内容,如果未能解决你的问题,请参考以下文章

markdown DevExpress Tab重新排序

markdown 列上的DevExpress工具提示

markdown DevExpress设置列标题BackColor

markdown DevExpress TreeList突出显示所选节点

基于所选行的 Devexpress MVC Gridview 自定义排序

DevExpress实现GridControl删除所有行的方法