I have a small C # 3.5 WinForms application that I am working on that grabs the names of event logs from the server into a list. When one of these items is selected, the other listview is populated with event log entries from the selected event log using the SelectedIndexChanged event, capturing the text property of the 1st item in the SelectedItems collection, as shown below.
string logToGet = listView1.SelectedItems[0].Text;
This works fine for the first time, but the second selection of the event log name from the first list does not work. It happens that the SelectedItems collection that the SelectedIndexChanged event receives is empty, so I get an ArgumentOutOfRangeException.
I'm at a loss. Any ideas on what I'm doing wrong or the best way to do this?
source
share