0
votes

I have a datawindow with checkboxes and a button 'OK'. The button is disabled until at least one of the checkboxes is checked. The problem is that if I have more than one checkbox checked and I want to uncheck one the button disables. I wrote the code in itemchanged event:

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

What am I doing wrong?

Thanks!

2

2 Answers

1
votes

You could put a hidden computed field in the detail band of your datawindow named cf_ind_count.

Define cf_ind_count

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

replace your script with

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
1
votes

The variable 'data' only applies to the current row. You need to use getitemstring.