Red Border on Focused Row
This is a better version of putting a red border on a focused row. Should work with DevExpress grid and treelist. Just add this code to the control's CustomDrawNodeCell event handler.
Private Sub tlSetupMenu_CustomDrawNodeCell(sender As Object, e As CustomDrawNodeCellEventArgs) Handles tlSetupMenu.CustomDrawNodeCell
Dim tree As TreeList
Dim graphic As Graphics = e.Graphics
Dim rectangle As Rectangle = e.Bounds
Dim brush As Drawing.SolidBrush = Nothing
Dim borderWidth As Single = 2
Try
If tlSetupMenu.FocusedNode IsNot Nothing Then
If tlSetupMenu.FocusedNode.Equals(e.Node) Then
tree = TryCast(sender, TreeList)
tree.Painter.DefaultPaintHelper.DrawNodeCell(e)
brush = New Drawing.SolidBrush(Color.Red)
If e.Column.VisibleIndex = 0 Then
graphic.FillRectangle(brush, New Rectangle(rectangle.X, rectangle.Y, borderWidth, rectangle.Height))
End If
If e.Column.VisibleIndex = tree.VisibleColumns.Count - 1 Then
graphic.FillRectangle(brush, New Rectangle(rectangle.Right - borderWidth, rectangle.Y, borderWidth, rectangle.Height))
End If
graphic.FillRectangle(brush, New Rectangle(rectangle.X, rectangle.Y, rectangle.Width + 1, borderWidth))
graphic.FillRectangle(brush, New Rectangle(rectangle.X, rectangle.Bottom - borderWidth, rectangle.Width + 1, borderWidth))
e.Handled = True
End If
End If
Catch ex As Exception
Throw
Finally
DHO.ReleaseUnmanagedResource(brush)
End Try
End Sub