Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
Creation Filters - Adding an image to a column header button


As the title suggests I am trying to use a creation filter to add a button to the column header with an image. A button gets added fine however I do not get an image. I am trying to add the image to the button by using an 'Apperance' but it does not appear to do anything, though setting other properties such as the cursor does, I just don't get it, any help please?

An additional issue is I appear to have a floating button, that randomly docks to the right for no reason. No idea what this is, it occurs even if I change the if statement to affect only one column.

My code is below:

    Public Sub AfterCreateChildElements(parent As Infragistics.Win.UIElement) Implements Infragistics.Win.IUIElementCreationFilter.AfterCreateChildElements

        Dim aButtonUIElement As ButtonUIElement = CType(parent.GetDescendant(GetType(ButtonUIElement)), ButtonUIElement)

        If IsNothing(aButtonUIElement) = True Then

            aButtonUIElement = New ButtonUIElement(parent)

        End If

       If IsNothing(aButtonUIElement.GetAncestor(GetType(HeaderUIElement))) = True Then

            Exit Sub

        End If

        Dim aColumnHeader As ColumnHeader = CType(aButtonUIElement.GetAncestor(GetType(HeaderUIElement)), HeaderUIElement).GetContext(GetType(ColumnHeader))

        If IsNothing(aColumnHeader) = False Then

            If Strings.Left(aColumnHeader.Column.Key, 5) = "Staff" And aColumnHeader.Column.Key <> "Staffing" And aColumnHeader.Column.Key <> "StaffAllocatedHours" Then

                If TypeOf parent Is HeaderUIElement = True Then



                    RemoveHandler aButtonUIElement.ElementClick, AddressOf _frmStaffing.OnButtonHeaderElementClick

                    AddHandler aButtonUIElement.ElementClick, New UIElementEventHandler(AddressOf _frmStaffing.OnButtonHeaderElementClick)

                End If

                Dim anAppearance As New Infragistics.Win.Appearance

                anAppearance.Cursor = Cursors.Cross 'Test to check anAppearance works, it does, the cursor changes to a cross.

                anAppearance.Image = My.Resources.edit_formula_add 'However the image is not shown.


                Dim rect As Rectangle = parent.RectInsideBorders


                ' adjust it slightly so that it fills the entire area of the row preview

                rect.Offset((parent.Rect.Width / 5) * 4, -2)


                ' set the width of the button's rect

                rect.Width = parent.Rect.Width / 5


                ' increase the height for aesthetic reasons

                rect.Height = rect.Height + 2

                ' set the button element's rectangle

                aButtonUIElement.Rect = rect

  ' set the appearance to draw the image.

                aButtonUIElement.Appearance = anAppearance

            End If

        End If

    End Sub