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
141
Image on ButtonUIElement
posted

Hi,

I am trying to have am image on the ButtonUIElement like the following:

 

Public Sub AfterCreateChildElements(ByVal parent As Infragistics.Win.UIElement) _

Implements Infragistics.Win.IUIElementCreationFilter.AfterCreateChildElements

If TypeOf parent Is GroupBoxHeaderUIElement Then

 

Dim img As Imageimg = Image.FromStream([Assembly].GetExecutingAssembly().GetManifestResourceStream("c:\Images\ABC.png"))

btnAddProblems = ButtonUIElement(parent)

btnAddProblems.Rect = New Drawing.Rectangle(New Drawing.Point(parent.Rect.X + 125, parent.Rect.Y + 1), _

New Drawing.Size(parent.RectInsideBorders.Width - 125, parent.RectInsideBorders.Height))

btnAddProblems.Appearance.ImageBackground = img

at this point I am geetin NullException Error because btnAddProblems.Appearance is Nothing  at this point

How could I resolve the probelm and and where should I write InitAppareance and how to invoke that method.

Please help.

Thanks.

 

 

 

 

 

 

 

Parents
  • 469350
    Offline posted

    Hi,

    I think this thread is getting a bit confused. So let's step back a moment. 

    First, you have posted your question in the WinGrid forum, but the element in your code is a GroupBoxHeaderUIElement, which has nothing to do with the grid as far as I know. 

    So to what, exactly, are you attempting to add a button? 

    Secondly, no matter where you are adding a button, you should not set the Appearance on the UIElement. This is never a good idea and probably won't work. If the element you are adding supports displaying images, then the proper way to supply an image would be to derive your own UIElement class and override InitAppearance. But I'm not entirely sure that ButtonUIElement supports images, so this may not work in this case. 

    If not, then the thing to do would be to have the CreationFilter add an ImageUIElement into the button during the call to BeforeCreateChildElements for the ButtonUIElement, and set the Image property on this ImageUIElement when you add it. 

Reply Children
No Data