'Adding the system context menu to right click event on item
I've been looking for a way to add the system context menu to my own item, and the only way i found is to make custom context menu. It works but the design is not like the default menu. Can someone help me with this.
Here is the code i tried:
private void topPanel_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}
else if (e.Button == MouseButtons.Right)
{
ContextMenu cm = this.ContextMenu;
cm.Show(topPanel, new System.Drawing.Point(20, 20));
}
}
At first look it work and doesn't show any error, but when i right click on the item it shows me this error: Object reference not set to an instance of an object.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
