private void contextMenuItem_Click(object sender, EventArgs e) { if (listView.SelectedItems.Count == 1) { MenuItemProviderMenuItem menuItem = (MenuItemProviderMenuItem)sender; HostListViewItem listViewItem = (HostListViewItem)listView.SelectedItems[0]; menuItem.MenuItemProvider.Execute(listViewItem.IpAddress); } }
private void listView_MouseUp(object sender, MouseEventArgs e) { // If the user right-clicks an item, show the context menu. if (e.Button == MouseButtons.Right) { HostListViewItem item = (HostListViewItem)listView.GetItemAt(e.X, e.Y); if (item != null && item.Selected) { contextMenu.Show(listView.PointToScreen(e.Location)); } } }
private void startButton_Click(object sender, EventArgs e) { listView.Items.Clear(); byte[] address = { byte.Parse(startAddress1TextBox.Text), byte.Parse(startAddress2TextBox.Text), byte.Parse(startAddress3TextBox.Text), 0 }; byte max = Math.Max(byte.Parse(startAddress4TextBox.Text), byte.Parse(endAddressTextBox.Text)); byte min = Math.Min(byte.Parse(startAddress4TextBox.Text), byte.Parse(endAddressTextBox.Text)); listView.BeginUpdate(); for (int i = min; i <= max; i++) { address[3] = (byte)i; // Create and add a new list view item to the list view. HostListViewItem lvItem = new HostListViewItem(new IPAddress(address)); listView.Items.Add(lvItem); // Instruct the list view item to ping, which kicks off the process of filling in the columns. lvItem.Ping(); } listView.EndUpdate(); }