Reputation: 18963
When i render contextmenustrip, it gets render at the top left of my PC Screen. I have a listview, which contains 5-6 items and on right click of each item, the context Menu strip gets displayed.Also i need to change the color of context menu strip including backgrounds and text as well.
Thanks in advance!
Upvotes: 1
Views: 1414
Reputation: 941218
By far the simplest way is to just set the ListView.ContextMenuStrip property to your CMS, everything is automatic then. You can do so in the designer.
If you need a custom handler for some reason, to check if the right item was clicked for example, then you can call the Show() method property with code like this:
private void listView1_MouseClick(object sender, MouseEventArgs e) {
if (allowContextMenu(listView1.SelectedItems) {
contextMenuStrip1.Show(listView1, e.Location);
}
}
Upvotes: 1
Reputation:
You haven't shown any code, but if you're not calling the Show
overload that takes a control as a parameter, the new Point(0, 0)
that your obviously passing will put the menu in the upper left of the screen.
Upvotes: 1