C#: How do you make sure that a row or item is selected in ListView before performing an action?
20,368
I'm not entirely sure what you are asking. Do you want to make sure at least 1 item is selected before running an action? If so the following should work
if ( listView.SelectedItems.Count > 0 ) {
// Do something
}
Or are you curious if a particular item is selected? If so try the following
if ( listView.SelectedItems.Contains(someItem)) {
// Do something
}
Author by
Admin
Updated on November 18, 2020Comments
-
Admin over 3 years
What is the best way to check if there is atleast a selected item in a listview or not in an if statement?
-
Marina Aguilar over 4 yearsWelcome to StackOverflow. Can you elaborate more on your answer?