?
Solved

Context Menus With Listview

Posted on 2004-08-18
6
Medium Priority
?
314 Views
Last Modified: 2008-03-10
Hi,

Im just trying to tidyup the user interface for the listview on my form.  The problem that im having is, I would like when the users RightClicks on a listviewItem for it to selcted(highlight) it fist before bringing up the contextmenu.

Also

While the contextmenu is displayed I have another anoying bug where if you click anywhere else on the form the contextmenu disapears and reapears very quickly so to make a contextmenu go away without selecting a option from it you have to efectivly click twice anywhere on the form :(

[Code Im using to display the contextmenu on the listview]

    Private Sub listmenu_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
        oCurrentNode = sender.GetItemAt(e.X, e.Y)

        'If Right mouse button is pressed
        If e.Button = MouseButtons.Right Then
            If Not Me.ContextMenu Is Nothing Then
                Me.ContextMenu.Show(Me, New Point(e.X, e.Y))
            End If
        End If
    End Sub



Regards

=Daniel=
0
Comment
Question by:emub
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 

Author Comment

by:emub
ID: 11829775
oCurrentNode is just a (global) "Private oCurrentNode As ListViewItem" on the form
0
 

Author Comment

by:emub
ID: 11829811
Hi,

Sorry I solved the first problem with addeding

Me.Items(oCurrentNode.Index).Selected = True

before displaying the contextmenu.

but the second problem is insits on having to click twice anywhere to get rid of the contextmenu :(
0
 
LVL 25

Accepted Solution

by:
RonaldBiemans earned 1400 total points
ID: 11829819
Instead of using the mousedown use the mouseup event (then it will select the item first)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:emub
ID: 11829846
Ah DOH!,  thx that solved both problems in 1 go dont need that .Slected line in any more :)
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 11829855
you are using mybase.mouse down which is the mousedown event of the form or are you using a custom listview control ?

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

shouldn't it be

   Private Sub listmenu_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles listmenu.MouseDown
0
 

Author Comment

by:emub
ID: 11829861
Im using a custom control that inherits ListView.  :)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

771 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