How to Handle events from a control array VB.net -
to start, hi im new stackoverflow, , new programing (on 1º year). i've been searching ive found nothing answer question, or maybe im newbie understand answers, im sorry if simple, cant see it!
/* native lenguage not english*/
here problem, i'm making vb form whit 200 pictureboxes have change or interact on click
i've made control array whit of them, this:
dim control(199) picturebox = controles(control, 0) function controles(byref control array, byval cont integer) each pic picturebox in me.controls control(cont) = pic cont += 1 next return control end function
this should asociate each picturebox array position, problem how can set event handler watch @ control().click no matter box click event onclick proc.
the way know create click handler each box manually.
hope can find answers
using addhandler
statement can wire them same routine. cast sender object interact pb clicked. oftype function.
private sub loadme() handles me.load each pb picturebox in me.controls.oftype(of picturebox)() 'add pb click events event sub addhandler pb.click, addressof pb_click next end sub private sub pb_click(sender object, e eventargs) dim pb = directcast(sender, picturebox) 'this pb clicked end sub
Comments
Post a Comment