【问题标题】:How to enable button according to the number of checked checkboxes powerbuilder?如何根据选中复选框powerbuilder的数量启用按钮?
【发布时间】:2017-08-21 09:15:41
【问题描述】:

我有一个带有复选框和“确定”按钮的数据窗口。该按钮被禁用,直到至少有一个复选框被选中。问题是,如果我选中了多个复选框并且我想取消选中其中一个,则按钮会禁用。我在 itemchanged 事件中写了代码:

int li_ind
long    ll_row

choose case dwo.name
    case "ind"
        for row = 1 to this.RowCount()
            if  data ='1' then      
                li_ind++
            end if
        next

        if li_ind <> 0 then
            parent.cb_ok.enabled = true
        else
            parent.cb_ok.enabled = false
        end if

end choose

我做错了什么?

谢谢!

【问题讨论】:

    标签: checkbox powerbuilder datawindow


    【解决方案1】:

    您可以在名为 cf_ind_count 的数据窗口的详细信息带中放置一个隐藏的计算字段。

    定义 cf_ind_count

    sum( if( ind = '1', 1, 0 ) )
    

    替换你的脚本
    long ll_count
    long ll_rows
    boolean lb_enable = false
    
    ll_rows = this.rowcount()
    
    if ll_rows < 1 then
        lb_enable = false
    else
        ll_count = long( this.object.cf_ind_count[1] )
        if ll_count > 0 then
            lb_enable = true
        else
            lb_enable = false
        end if
    end if
    
    parent.cb_ok.enable = lb_enable
    

    【讨论】:

      【解决方案2】:

      变量“数据”仅适用于当前行。您需要使用 getitemstring。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-09-11
        • 1970-01-01
        • 2020-11-23
        • 2019-06-02
        • 2018-01-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多