private void myListView_ItemClick(object sender, ItemClickEventArgs e) { // Do something with the clicked item ListViewItem clickedItem = (ListViewItem)e.ClickedItem; MessageBox.Show("You clicked on " + clickedItem.Text); }
private void myListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { // Do something with the selected item ListBoxItem selectedItem = (ListBoxItem)e.AddedItems[0]; MessageBox.Show("You selected " + selectedItem.Content); }This example shows how to handle the ListItem Click event in a ListBox. When the user clicks on an item in the ListBox, a MessageBox is displayed showing the content of the selected item. Package library: System.Windows.Controls.ListBox or System.Windows.Forms.ListBox