Results 1 to 4 of 4

Thread: Listview Select Problem - Run code

  1. #1

    Thread Starter
    Hyperactive Member gmatteson's Avatar
    Join Date
    Feb 2002
    Location
    Rhode Island, USA
    Posts
    293

    Listview Select Problem - Run code

    I have 4 items in my listview, the listview in in large icon mode.
    I want it so that when a user clicks on item 1, a peice of code activates, and do that for each of the 4 items, each peice of code is different. I was thinking about doing it in a select case, but I don't know how to, I am using VB.net. Thank you for you time,
    - Gabe

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Try this code ,

    VB Code:
    1. Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
    2.         Dim i As Integer = 0
    3.         For i = 0 To ListView1.Items.Count - 1
    4.  
    5.             If ListView1.Items(i).Selected = True Then
    6.                 Select Case ListView1.Items(i).Index
    7.                     Case 0
    8.                         MsgBox("Case 0 fired")
    9.                         'Do your this
    10.                     Case 1
    11.                         MsgBox("Case 1 fired")
    12.                         'Do your this
    13.                     Case 2
    14.                         MsgBox("Case 2 fired")
    15.                         'Do your this
    16.                     Case 3
    17.                         MsgBox("Case 3 fired")
    18.                         'Do your this
    19.                 End Select
    20.             End If
    21.         Next
    22.  
    23.     End Sub

  3. #3

    Thread Starter
    Hyperactive Member gmatteson's Avatar
    Join Date
    Feb 2002
    Location
    Rhode Island, USA
    Posts
    293

    Thank you.

    Thank you, works perfectly.

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: Thank you.

    Originally posted by gmatteson
    Thank you, works perfectly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width