vb.net - How can I identify which dynamically added picturebox is currently selected during mouseenter -


i dynamically created 5 picture box , added events mouseenter , mouseleave, problem when hover cursor on 1 of picture box, other trigger event

private sub form_test_load(sender object, e eventargs) handles mybase.load      dim imgselect picturebox     dim x integer = 1      while not x = 5          imgselect = new picturebox         imgselect.name = "image0" & x.tostring         imgselect.backcolor = color.black         imgselect.size = new size(203, 312)         imgselect.borderstyle = borderstyle.fixedsingle         imgselect.visible = true         imgselect.bringtofront()         imgselect.sizemode = pictureboxsizemode.stretchimage          flowlayoutpanel1.controls.add(imgselect)          x += 1          addhandler imgselect.mouseenter, addressof imgselect_mouseenter         addhandler imgselect.mouseleave, addressof imgselect_mouseleave      end while  end sub 

in mouse enter event handler, can ui control trigger event sender parameter :

private sub imgselect_mouseleave(sender object, e system.eventargs)     dim currentimage picturebox = directcast(sender, picturebox)     ...... end sub  

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -