User chose a folder containing files. I’m making a listview displaying the files in the chosen folder. I want to display what each file contains, but i want to display it when the user checks a file from listviewitem. I’m using the following code:
if (listView1.Items[0].Checked == true)
{
//....
}
Why doesn’t it work? What should i want to use data from for example:
button1.Click(...) to button2.Click(...)?
Which event are you capturing? Remember if it’s the
ItemCheck, that you cannot use thelistView1.Item[0].Checkedif that item was what was checked/unchecked. You need to take theItemCheckEventArgsparameter, and using thee.Index, exclude that element when checking the entire listview elements. Usee.NewValueto separately evaluate the item that raised theItemCheckevent.