vb.net - How to open a new windows form by clicking on a listview item -


as title said want open new specif window each item clicked in listview contents page. code have far is...

private sub lvlesson_doubleclick(sender object, e eventargs) handles lvlesson.doubleclick     if lvlesson.fullrowselect.tostring = "lesson 4"         messagebox.show("hello")     end if end sub 

the messagebox test. have 4 items lesson 1, 2, 3, 4 want click on 1 or 2 etc , open form 1 or 2 etc.

the documentation friend.

fullrowselect boolean property indicating whether full row selected or not when item clicked.

you want selecteditems property. gives access items of listview selected.

for example:

private sub listview1_doubleclick(sender object, e eventargs) handles listview1.doubleclick     'check have selected     if listview1.selecteditems.count > 0         'find out items selected , open appropriate form         select case listview1.selecteditems(0).text             case "lesson 1"                 messagebox.show("open form 1")             case "lesson 2"                 messagebox.show("open form 2")             case "lesson 3"                 messagebox.show("open form 3")             case "lesson 4"                 messagebox.show("open form 4")         end select     end if end sub 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -