Monday, 15 July 2013

.net - Passing a list's items by Reference within Vb.net application -



.net - Passing a list's items by Reference within Vb.net application -

i'd alter content of list of boolean, passed method reference :

dim liste new list(of boolean) liste.add(lbl1.visible) liste.add(lbl2.visible) raiseevent rgprocs9selection(liste, selectedindex)

in method :

private sub rgprocs9selectionmethod(byref composantsvisibility list(of boolean), byval selectedindex integer) composantsvisibility.clear() if selectedindex = 0 index integer = 0 1 composantsvisibility.add(false) next else index integer = 0 11 composantsvisibility.add(true) next end if end sub

the content values of list changed visiblity of labels (lbl1, lbl2) still same.

so, need know why items aren't passed reference? how can prepare code

you need two lists. 1 visibility , 1 labels:

dim liste new list(of boolean) dim listel new list(of label) liste.add(lbl1.visible) liste.add(lbl2.visible) listel.add(lbl1) listel.add(lbl2) raiseevent rgprocs9selection(liste, listel, selectedindex)

and in end of rgprocs9selectionmethod:

private sub rgprocs9selectionmethod(byval composantsvisibility list(of boolean), byval composantslabels list(of label), byval selectedindex integer) ... ... = 0 composantslabels.count - 1 composantslabels(i).visible = composantsvisibility(i) next end sub

.net vb.net winforms collections reference

No comments:

Post a Comment