[英]In my ListView control, is there a way for me to GET the index of a clicked item?
非常简单的问题,但我找不到解决方法。
当用户双击我的ListView中的项目时,我想保存所单击项目的索引号。
假设您对ListViewItem有引用:
listView.Items.IndexOf(listViewItem)
或者只访问Activate事件处理程序中的listView.SelectedIndices
-如果您的ListView是单选的,则那里将只有一个索引。
这取决于您所使用的ListView 。 这三个都具有获取所选项目的索引的属性:
对于Windows窗体,请使用ListView.SelectedIndices
对于WPF,请使用ListView.SelectedIndex
对于Web,请使用ListView.SelectedIndex
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.