【问题标题】:Number of items in a combobox in FlexFlex 组合框中的项目数
【发布时间】:2010-04-16 20:10:39
【问题描述】:

嗨, 如何在 Flex 中检索组合框的项目总数(计数)?

【问题讨论】:

    标签: apache-flex combobox count


    【解决方案1】:

    给你的随机想法:

    var dp : Object = combobox.dataProvider ;
    if(dp is Array)
    {
        //do something cool
    }
    else if(dp is ArrayCollection){
        //do something equally as cool
    }
    

    等等……

    【讨论】:

      【解决方案2】:

      我已经确认这会起作用:

      (comboBox.dataProvider as ArrayCollection).length
      

      【讨论】:

      • 您假设 dataProvider 是一个 ArrayCollection。它也可以是一个数组。请参阅 jeremy.mooer 的回答。
      【解决方案3】:

      尝试使用:

      combobox.collection.length
      

      combobox 是您正在使用的组合框

      我不确定这是否可行。您可能需要对控件进行子类化,因为集合是受保护的成员:(

      【讨论】:

        【解决方案4】:

        combobox 的数据提供者是一个数组集合。您可以使用长度属性来计算数字。

        【讨论】:

        • 错了!这是一个只写属性。
        • 也许,不清楚。我的意思是arraycollection的length属性。
        • dataprovider 是只写属性。
        • 我认为他的意思是他会把arraycollection放在那里,这样他就可以回到原来的参考并取它的长度。
        • 蒂姆,是的,这就是我的意思。
        猜你喜欢
        • 2011-04-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-08-09
        • 1970-01-01
        相关资源
        最近更新 更多