Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a listview.i want to popup a context menu when i rightclick an item of the listview. how can i locate the contextmenu near my selected item?
Posted
Comments
CodeHawkz 5-May-11 1:32am    
I hate to say this, but if you Google these 2 things, you will get MORE than you want. I really do not know why, you can't do it. You can't be a developer if you don't do 2 simple things (1. Research 2. Trial and error).
Sergey Alexandrovich Kryukov 5-May-11 16:10pm    
Agreed. This note can be more valuable to OP then the direct answer. OP should consider such criticism constructively, only then there can be the help.
--SA

1 solution

Try Given code

C#
private void listView1_MouseClick(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Right)
    {
        ListViewHitTestInfo hitTestInfo = listView1.HitTest(e.X, e.Y);
        if (hitTestInfo.Item != null)
        {
            contextMenuStrip1.Show(listView1, e.X, e.Y);
        }
    }
}
 
Share this answer
 
Comments
RAJI @Codeproject 5-May-11 1:52am    
thanks!!!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900