vb.net - Handle all of an array's events -
so have class contains few controls easy ui design , has custom event raised whenever combo box inside panel changed:
public class batinputline inherits system.windows.forms.panel public event selectionchanged eventhandler protected overridable sub onselectionchanged(byval e eventargs) raiseevent selectionchanged(me, e) end sub private sub nameset(sender object, e eventargs) handles_cboname.selectedindexchanged playername = _playernames(_cboname.selectedindex) selectedindex = _cboname.selectedindex onselectionchanged(eventargs.empty) end sub
an array of these declared , user inputs number according how many of these need on screen on new form.
redim _batinputs(getnumberofbatsmen())
i want call sub procedure whenever selectionchanged event raised of instances of batinputline in _batinputs(). if try write handler e.g sub dosometing(sender object, e eventargs) handles _batinputs(0).selectionchanged error saying that _batinput elements need declared withevents modifier, don't quite know how them.
a) how can declare array of indexes withevents modifier?
b) how can assign sub procedure called when these events raised, in new form?
made use of addhandler keyword, didn't know existed.
for = 0 _batinputs.length -1 addhandler _batinputs(i).selectionchanged, addressof handleselectionchangedevent next private sub handleselectionchangedevent 'do end sub
Comments
Post a Comment