Private _theFocusPen As Pen = Nothing Private _xOffset As Integer = 0 Private _yOffset As Integer = 0 Private _wOffset As Integer = 0 Private _hOffset As Integer = 0 Public Sub New(ByVal theFocusPen As Pen, ByVal xOffset As Integer, ByVal yOffset As Integer, ByVal wOffset As Integer, ByVal hOffset As Integer) _theFocusPen = theFocusPen _xOffset = xOffset _yOffset = yOffset _wOffset = wOffset _hOffset = hOffset End Sub Public Function DrawElement(ByVal drawPhase As Infragistics.Win.DrawPhase, ByRef drawParams As Infragistics.Win.UIElementDrawParams) As Boolean Implements Infragistics.Win.IUIElementDrawFilter.DrawElement Dim retVal As Boolean = False 'if we return FALSE then none of 'this custom code will be used by the user of this Draw Filter. 'Returning True insures that this custom code is used. 'It is good practice to test which DrawPhase is calling 'this method. You may have configured this DrawFilter to 'be used in more than one DrawPhase. If drawPhase = Infragistics.Win.DrawPhase.BeforeDrawFocus Then Dim regularRect As Rectangle = drawParams.Element.Rect 'This is the Element's full rectangle Dim clippedRect As Rectangle = drawParams.Element.ClipRect 'If the element is being clipped by other elements, this is its Clipped off rectangle Dim theFocusRectangle As Rectangle 'Test to see if the element is getting clipped off 'by another element. If (clippedRect.Width < regularRect.Width) OrElse (clippedRect.Height < regularRect.Height) Then theFocusRectangle = clippedRect Else theFocusRectangle = regularRect End If 'This allows us to change the actual rectangle and tweak its size. This is needed 'so that you can tweak theFocusRectangle = New Rectangle(theFocusRectangle.X + _xOffset, theFocusRectangle.Y + _yOffset, theFocusRectangle.Width + _wOffset, theFocusRectangle.Height + _hOffset) 'At this point, we have a Rectangle that outlines the 'Element that is going to have a Focus Rectangle drawn 'on top if it. drawParams.Graphics.DrawRectangle(_theFocusPen, theFocusRectangle) retVal = True 'ensure that this custom code is applied. End If Return retVal End Function