private void listView2_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { try { if (listView2.FocusedItem.Bounds.Contains(e.Location) == true) { ItemContexMenu.Show(Cursor.Position); //selectedItem = listView2.SelectedItems[0].Index; foreach (var item in items) { if (item.displayName == listView2.SelectedItems[0].Text) { selectedItem = item.id; } } //MessageBox.Show($"{selectedItem} = {items[selectedItem].hostName}"); } else { //if(listView1.) ListViewMenu.Show(Cursor.Position); } } catch { ListViewMenu.Show(Cursor.Position); } } }
///////////////////////////////////////////////////////////////////// Работа с элементами коллекции ////////////////////////////////////////////////////////////////// private void listView1_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { try { if (listView1.FocusedItem.Bounds.Contains(e.Location) == true) { ItemContexMenu.Show(Cursor.Position); selectedItem = listView1.SelectedIndices[0]; //MessageBox.Show($"{selectedItem} = {items[selectedItem].hostName}"); } else { //if(listView1.) ListViewMenu.Show(Cursor.Position); } } catch { ListViewMenu.Show(Cursor.Position); } } }