Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi ppl,

 

I have populated my listview with items form by database. I now want to add 2 context menu for diferent purpose im my list view:

 

1. If a user right clicks in an item that exist in my list view i want to show a context menu with options like "properties", "Delete", "edit", etc.

 

2. If a user right clicks in the list view where there is no items i want to show a diferent context menu like "add new item", "refresh", "list view", etc

 

How can i do this? how do i know that the user right clicked on an item?

 

thanks to all

Posted

The following seems to work:

 

   Private Sub ListView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseDown

       If Not (ListView1.GetItemAt(e.X, e.Y) Is Nothing) Then
           ListView1.ContextMenu = mnuItem
       Else
           ListView1.ContextMenu = mnuNoItem
       End If

   End Sub

Here's what I'm up to.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...