Why can't I see any selected items?

I try to do somthing when the user select item in the ListView. I have tried this code:

private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            q = listView1.SelectedItems[0].Index;
        }

but it doesn't work and throws an exception that says that the count of 'listView1.SelectedItems' is 0.

Why doesn't it work?


Always check for the listview items count. If items are empty then there will be an exception.

链接地址: http://www.djcxy.com/p/50334.html

上一篇: 如何在创建3层项目备份时获得.bak扩展名

下一篇: 为什么我看不到任何选定的项目?