Results 1 to 4 of 4

Thread: Confused ListView Right Click

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2009
    Location
    Scotland/Japan
    Posts
    164

    Confused ListView Right Click

    Hey i have been working ON a mailing app for a company that is all SQL based i have most of it working but theres one thing that has me confused

    it errors out if you right click and theres no name selected

    vb Code:
    1. Private Sub ListView2_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView2.MouseClick
    2.         If e.Button = Windows.Forms.MouseButtons.Right Then
    3.             Dim myListView As ListView 'Assign your ListView here.
    4.             myListView = ListView2
    5.             For itemIndex As Integer = 0 To myListView.SelectedItems.Count - 1
    6.                 For subitemIndex As Integer = 1 To myListView.Columns.Count - 1
    7.  
    8.                     If myListView.SelectedItems(itemIndex).Text = "" Then
    9.                         MsgBox(" You Need To Select A UserName")
    10.                         ContextMenuStrip3.Close()
    11.                     Else
    12.  
    13.                         ContextMenuStrip3.Show()
    14.                         USERNAMEToolStripMenuItem.Text = myListView.SelectedItems(itemIndex).Text
    15.  
    16.  
    17.  
    18.  
    19.                     End If
    20.  
    21.                 Next
    22.             Next
    23.         End If
    24.     End Sub

    i have tryed that code in the contect menu opening sub and also int he click sub but both dont work can anyone help me figure out ware i have gone Wrong
    Between the world we see and the things we fear theres a realm of possibility

    D.L.H. Ind.

    We do what we do in out life to make Yours Simpler

  2. #2
    Fanatic Member
    Join Date
    Aug 2009
    Posts
    540

    Re: Confused ListView Right Click

    so at line 8 you're expecting the code to enter into the error message code block if they right click on no name? Have you set a break point at this line and tested to see what value myListView.SelectedItems(itemIndex).Text contains when you perform this action?
    Where I'm from we only have one bit of advice for new comers: "If you hear banjos, turn and run".


    VS 2008 .NetFW 2.0

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2009
    Location
    Scotland/Japan
    Posts
    164

    Re: Confused ListView Right Click

    ok i tryed that i added a msgbox that should popup and display the value of the item

    BUT wheni right click on the control nothing happens

    so is there something wrong with my right click code or something
    Between the world we see and the things we fear theres a realm of possibility

    D.L.H. Ind.

    We do what we do in out life to make Yours Simpler

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jul 2009
    Location
    Scotland/Japan
    Posts
    164

    Re: Confused ListView Right Click

    ok so i done some looking and its my right click that isnt working right soo im at a loss
    Between the world we see and the things we fear theres a realm of possibility

    D.L.H. Ind.

    We do what we do in out life to make Yours Simpler

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