Solved

VB.net ListView ContextMenuStrip on ListView right click to delete item

Posted on 2014-02-04
5
7,185 Views
Last Modified: 2014-02-05
Hi

What VB.net code would I use to enable a user to right click on
a ListView item then delete that item

Thanks
0
Comment
Question by:murbro
  • 3
  • 2
5 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 39835499
For built in controls, you would have to use code to do this

Private Sub listView1_MouseClick(sender As Object, e As MouseEventArgs)
      If e.Button = MouseButtons.Right Then
            If listView1.FocusedItem.Bounds.Contains(e.Location) = True Then
                  contextMenuStrip1.Show(Cursor.Position)
            End If
      End If
End Sub


Are you using those 3rd party controls?
0
 

Author Comment

by:murbro
ID: 39835527
I am using built in controls
0
 

Author Comment

by:murbro
ID: 39835558
How do I gather the ListView item that I clicked on so that I can delete it
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39835673
When you show the contextmenu in MouseClick event, save the X and Y location. Then use HitTest method of listview to find the item where mouse was clicked

http://msdn.microsoft.com/en-us/library/f7548bw9(v=vs.110).aspx
0
 

Author Closing Comment

by:murbro
ID: 39835727
Thanks
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Ajax Panel Not Updating When Triggered By Timer 4 72
VB.net Move a class from Solution Items to a project 2 23
Disable extension 8 38
location of a form 2 14
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question