【发布时间】:2010-08-27 16:39:20
【问题描述】:
我正在开发一个小型 C# 3.5 WinForms 应用程序,该应用程序将事件日志名称从服务器抓取到列表视图中。 When one of those items is selected, another listview is populated with the event log entries from the selected event log using the SelectedIndexChanged event by grabbing the text property of the 1st item in the SelectedItems collection as shown below.
string logToGet = listView1.SelectedItems[0].Text;
这第一次工作正常,但从第一个列表视图中第二次选择事件日志名称失败。发生的事情是 SelectedIndexChanged 事件正在获取的 SelectedItems 集合为空,因此我得到了 ArgumentOutOfRangeException。
我很茫然。关于我做错了什么或更好的方法的任何想法?
【问题讨论】:
标签: c# winforms listview selectedindexchanged