How about 1 message box with all items selected?
List<string> selectedList = new List<string>(); foreach (var item in listBox1.SelectedItems) { selectedList.Add(item.ToString()); } if (selectedList.Count() == 0) { return; } MessageBox.Show("Selected Items: " + Environment.NewLine + string.Join(Environment.NewLine, selectedList));
If any is selected, this should give you a line for each selected item in your message box. There is probably a more convenient way to do this with linq, but you did not specify a .NET version.
source share