[resolved] context Menu Position in Listview
HI
I want to display the contextMenu once the user right-click in listview,
but I can't make it to the click position.
any idea ?
cms_lvw_product.Show(listView1, new Point(Control.MousePosition.X, Control.MousePosition.Y));
the position is not exactly on the click position.
Re: context Menu Position in Listview
This can be archived by assigning the 'ContextMenuStrip ' property of the control to the ' contextMenuStrip' control this can be done at design or runtime.
Code:
this.TabPage1.ContextMenuStrip = contextMenuStrip1;
Hope This Helps!!!
:wave: :thumb: :wave:
Re: context Menu Position in Listview
listView1 is the ListView component;
cms_lvw_product is the Context Menu.
listView1.ContextMenuStrip = cms_lvw_product;
listView1.ContextMenuStrip.Visible = true;
however the context menu is still showing up in Right Top corner
appreciate any help.
Re: context Menu Position in Listview
where are you assigning the menu better to do it a desgin time or in the constructor of the form, this works for me.
Code:
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
this.listView1.ContextMenuStrip = this.contextMenuStrip1;
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
Re: context Menu Position in Listview
once you did Right-Click first, it works fine on left/right mouse click
but
If you did Left Click first, then the menu will display in Top/Right corner,
until you click the Right Click, then it become to the correct position.
is a bug there or I should set something up?
otherwise How could I disable LEFT mouse click ?
Re: context Menu Position in Listview
More info:
the problem maybe come with click event ??
private void listView1_Click(object sender, EventArgs e)
{
listView1.ContextMenuStrip = cms_lvw_product;
listView1.ContextMenuStrip.Visible = true;
}
Re: context Menu Position in Listview
resolved
remove listView1.ContextMenuStrip.Visible = true;
it works fine now
Thx again