luc*_*luc 1 c# event-handling listviewitem winforms
用户选择一个包含文件的文件夹。我正在制作一个列表视图,显示所选文件夹中的文件。我想显示每个文件包含的内容,但我想在用户从 listviewitem 检查文件时显示它。我正在使用以下代码:
if (listView1.Items[0].Checked == true)
{
//....
}
Run Code Online (Sandbox Code Playgroud)
为什么不起作用?我应该使用什么数据,例如:
button1.Click(...)到button2.Click(...)?
不确定您到底在寻找什么,但有多种方法可以确定检查 ListView 中的哪些项目:
// This loops through only the checked items in the ListView.
foreach (ListViewItem checkedItem in listView1.CheckedItems) {
// All these ListViewItems are checked, do something...
}
// This loops through all the items in the ListView and tests if each is checked.
foreach (ListViewItem item in listView1.Items) {
if (item.Checked) {
// This ListViewItem is Checked, do something...
}
}
Run Code Online (Sandbox Code Playgroud)
您可以使用ListViewItem类来检查每个选定项目的详细信息。
| 归档时间: |
|
| 查看次数: |
15996 次 |
| 最近记录: |