This is all possible with standard events. In this code, I assume contextMenuStrip1 is the ContextMenuStrip for listView1 and contextMenuStrip is a second strip for use when the column header is clicked.
private void listView1_AfterLabelEdit(object sender, LabelEditEventArgs e) { Console.WriteLine("Item {0} changed from {1} to {2}", e.Item, listView1.Items[e.Item].Text, e.Label); } private void contextMenuStrip1_Opening(object sender, CancelEventArgs e) { // Check if header area was clicked Point pos = listView1.PointToClient(Control.MousePosition); Rectangle rect = listView1.TopItem.Bounds; if (pos.Y < rect.Top) { e.Cancel = true; contextMenuStrip2.Show(listView1, pos); } }
|