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
310
ComboBoxTool and ScaleItemImage
posted

Hi,

I have the problem that when an item is selected in a ComboBoxTool its image is scaled . Within the dropdown list the image is displayed in its original size (which is 32x16), but when the selected item is displayed in the textbox part of the control the image is scaled to 16x16.

I found this older post regarding the same topic suggesting a creation filter:

http://forums.archive.infragistics.com/readmessage?id=%3C7134a801$2f13dfff$39803@news.infragistics.com%3E&group=infragistics.products.netadvantage.windowsforms.wintoolbars

This didn't work out for me as scaling seems not to be affected by the filter. I wrote a DrawFilter instead with the result that the image is not scaled anymore, but now cropped to 16x16. Attempting to move the rects of the text element to the right was successful, but the size of the image is still 16x16.

My DrawElement method looks like this:

    public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams)
    {
      ImageUIElement ie = drawParams.Element as ImageUIElement;
      if (ie.Image.Size.Width == 32)
      {
        ie.Scaled = false;
        ie.Rect = new Rectangle(ie.Rect.X, ie.Rect.Y, 32, 16);

        foreach (UIElement child in ie.Parent.ChildElements)
        {
          if (child.Equals(ie))
            continue;
         
          Rectangle childRect = child.Rect;
          if (childRect.Left < ie.Rect.Right)
          {
            childRect.Width -= ie.Rect.Right - childRect.Left;
            childRect.X += ie.Rect.Right - childRect.Left;
            child.Rect = childRect;
          }
        }
      }
      return false;
    }

Any help what I am missing?

Regards,

Torsten