listview FocusedItem选择了不正确的文件 [英] listview FocusedItem incorrect file selected
本文介绍了listview FocusedItem选择了不正确的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
伙计我有一个包含13个文件的列表视图.当我选择一个以新表格打开时,我似乎将上一个文件的详细信息拖到了新表格中.
有人知道为什么会这样吗?
代码:
Hi guy. I have a listview populated with 13 files. When i select one to open in a new form i seem to get the last file''s details pulled to the new form.
Does anybody know why this happens?
Code:
if (lstfiles.SelectedItems.Count! = 0)
{
if (lstfiles.Items[0].Selected)
{
string file = lstfiles.FocusedItem.Text;
openFormGeneral(file);
}
}
private void openFormGeneral(string FilePath)
{
General gen = new General();
gen.title = title;
gen.Show();
}
推荐答案
我不确定我是否完全理解您的代码.
尝试在SelectedIndexChanged
事件 [ ^ ].
这将使用this.ListView1.SelectedItems
为您提供正确的项目列表,并使用该数据打开表单.
I''m not quite sure I understand your code completely.
Try using the new form inside aSelectedIndexChanged
event[^].
This will give you the right item list usingthis.ListView1.SelectedItems
and open the form with that data.
所选项目和重点项目不必相同.
试试:
Selected and focussed item do not need to be the same.
Try:
if (lstfiles.SelectedItems.Count > 0 )
{
string file = lstfiles.SelectedItems[0].Text;
openFormGeneral(file);
}
这篇关于listview FocusedItem选择了不正确的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文