i want run 1 block of code when of 197 checkboxes on form clicked. have of checkboxes in array used check availability of each seat on forms load (this program seat booking system). each seat checkbox displayed button, , "seats selected" label show seat selected once has been checked. used same array in code below check whether checked, , if label updated. code below giving me error described "object reference not set instance of object" when click 1 of checkboxes. i'm not sure why , can't find solution. coding first 3 checkboxes @ moment, see if works. ideally list 197 checkboxes handles procedure, when clicked every seats checkstate checked.
if has solution great! thanks.
public class frmseatplan dim seat(11, 20) control private sub a1_checkedchanged(byval sender system.object, byval e system.eventargs) handles a1.checkedchanged, a2.checkedchanged, a3.checkedchanged seat(1, 1) = a1 seat(1, 2) = a2 seat(1, 3) = a3 y = 1 1 x = 1 3 dim seat(y, x) checkbox if seat(y, x).checked = true selectedseats = selectedseats & seat(y, x).name & ", " msgbox(selectedseats) lblselected.text = selectedseats end if next x next y end sub
are going write handles clause 197 times? can sure time finished did not make mistake? if add seat #198 between #156 , #157 - how go around it? gradually planning maintenance nightmare yourself. instead, should bind events in code, create checkboxes. way never have problem getting.
for y = 1 3 x = 1 3 dim chk new checkbox 'set positioning on screen chk.x = x chk.y = y addhandler chk.checkedchanged, addressof any_checkedchanged next next
ideally, not need array well, i.e. seat(y, x)
, because every seat can assigned x , y when created , pass event arguments (so need custom event).
Comments
Post a Comment