2 Replies Latest reply on Oct 18, 2007 2:02 AM by kcell

    100% width on ComboBox

    Dzihan Level 1
      Hi all,

      i got a ComboBox 100% width inside a HDividedBox. When i resize the parent DivBox canvas the ComboBox resizes correctly.

      When the ComboBox contains a longer entry than the DivBox canvas the Combo shows the long entry completely and scrollbars appear on the canvas.

      Anyone knows how to avoid the Combo takes the width of its widest child?

      Thx in advance!
        • 1. Re: 100% width on ComboBox
          Robert Hirst
          The simplest way I found was to extend the ComboBox component and override the method which seems to cause this behaviour with a dummy method.

          I created an .as class file which looks something like this:

          package
          {
          import mx.controls.ComboBox;

          public class RestrictedWidthComboBox extends ComboBox
          {
          override protected function calculatePreferredSizeFromData(count:int):Object
          {
          return { width: 0, height: 0};
          }
          }
          }


          Now you can use this combo box exactly as you would use a normal combo box.

          <local:RestrictedWidthComboBox y="95" width="100%" dataProvider="{datafields}" x="0"/>

          Hope that helps, let me know if that's the behaviour you expected.
          • 2. 100% width on ComboBox
            kcell Level 2
            Hi Robert,

            thanks a lot, I achieved the same problem and your solution fits perfect ;)

            best regards,
            kcell