How to pop-up menu

  • Thread starter Thread starter David
  • Start date Start date
D

David

Hello to everybody...
I just want to ask how to make context menu to pop-up when user of my
program right cklicked on ListView Item...

thanx...
 
hi David

Follow these steps to do what you want

1 - Drag a context menu from the Visual Studio Toolbox , name it "myContext"

2 - Right click on your listview and choose "Properties" then scrool down
to a property called "Context Menu" and click to choose the "myContext"

good Luck
 
Create a context menu for the form and assign it to the ContextMenu property
of the ListView control..


Hello to everybody...
I just want to ask how to make context menu to pop-up when user of my
program right cklicked on ListView Item...

thanx...
 
thanx for reply...
it works when i right click on ListView, but i want it to pop-up only when
List View ^Item^ was right clicked...
 
thanx for reply...
it works when i right click on ListView, but i want it to pop-up only when
List View ^Item^ was right clicked...
 
Hi,

you dont have to bind the context menu to your listview.

// MouseDown event of your listbox
private void listView1_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
Point p = new Point(e.X, e.Y);
if(e.Button == MouseButtons.Right)
{
ListViewItem item = this.listView1.GetItemAt(p.X, p.Y);
if(item != null)
{
this.contextMenu1.Show(this.listView1, p);
}
}
}
 
Back
Top