vb.net - Set CheckBox Checked based on CheckBoxes of a GroupBox -


good morning want ask related in checkboxes have groups of checkboxes , looks this

enter image description here

my question how can check checkbox purchase requisition whenever check checkbox in group purchase requisition , if of them uncheck checkbox purchase requisition unchecked.

i have code , put code on of checkbox inside groupbox purchase requisition

  sub check_purchase_req()         dim octl control         dim ix integer          each octl in groupbox3.controls             if typename(octl) = "checkbox" , octl.enabled = true ix = ix + 1              if ix > 0                 checkbox1.checked = true              elseif checkbox19.checked = false , checkbox20.checked = false , checkbox21.checked = false , checkbox22.checked = false , checkbox23.checked = false                  checkbox1.checked = false                 exit             end if         next     end sub 

but code doesnt meet need

any appreciated tysm

here, checkbox1 checkbox5 assumed named of checkboxes inside purchase requisition group box.

chkpurchaserequisition checkbox purchase requistion checkbox

try one:

 private sub checkbox1_checkedchanged(byval sender system.object, byval e system.eventargs) handles _ checkbox1.checkedchanged, checkbox2.checkedchanged, checkbox3.checkedchanged, checkbox4.checkedchanged, checkbox5.checkedchanged     if sender.checked = true         chkpurchaserequisition.checked = true     else         dim allunchecked boolean = true         each c control in grpboxpurchaserequisition.controls.oftype(of checkbox)()             if directcast(c, checkbox).checked = true                 allunchecked = false                 exit             end if         next         if allunchecked = true             chkpurchaserequisition.checked = false         end if     end if  end sub 

Comments