vb.net - dynamically creating buttons in code in vb2010 -
i'm working in vb2010 , think can create button array in code; however, i'm struggling refer created buttons individually code click events work @ runtime.
any help appreciated. i'm new vb programmimg go easy on me!!
give try:
' many buttons want dim numbuttons integer = 5 dim buttonarray(numbuttons) button dim integer = 0 each b button in buttonarray b = new button addhandler b.click, addressof me.buttonsclick b.tag = "b" & ' can set things button text in here. += 1 next private sub buttonsclick(sender object, e system.eventargs) ' sender button has been clicked. can ' you'd it, including cast button. dim currbutton button = ctype (sender, button) select case currbutton.tag case "b0": ' first button in array. things! case "b1": ' sec button in array. things! case "b2": ' notice pattern? '... end select end sub
vb.net button addhandler
No comments:
Post a Comment