Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在listview中修改项目后自动聚焦_C# - Fatal编程技术网

C# 在listview中修改项目后自动聚焦

C# 在listview中修改项目后自动聚焦,c#,C#,我的windows窗体上有一个列表视图,其中大约有200个项目。我的问题是,如果我发现某个项目有拼写错误或其他错误。因此,当我选择该项目,然后在列表视图中重新修改时,我希望关注该特定项目 现在,我正在这样做:- listView1.Items[this.listView1.Items.Count - 1].EnsureVisible(); //i know that this code is for focusing on the very last item. 请帮帮我 广告中的谢

我的windows窗体上有一个
列表视图
,其中大约有200个项目。我的问题是,如果我发现某个项目有拼写错误或其他错误。因此,当我选择该项目,然后在
列表视图中重新修改时,
我希望关注该特定项目

现在,我正在这样做:-

    listView1.Items[this.listView1.Items.Count - 1].EnsureVisible();
 //i know that this code is for focusing on the very last item.
请帮帮我

广告中的谢谢:)

试试看

listView1.SelectedItems[0].EnsureVisible();
如果要将第一个选定项目带到视图中

或者,如果要选择特定项目:

listView1.Items[i].Selected = true;

这取决于你到底想做什么

编辑:

如果要在修改项目后聚焦列表视图,可以编写:

void btnModify_Click(object sender, EventArgs e)
{
    // change the item...

    // focus the list view
    listView1.Select();
}

你的密码有什么问题?我的密码没有问题。我只想关注我在单击更新按钮后在列表视图中修改的特定项目。您的“特定项目”是什么?您是否有项目的索引,或
ListViewItem
对象?是的,我有特定项目的索引号。假设listview“Podim”中有一个项目,当我查看所有项目时,我发现dat特定项目的拼写错误,它应该是“Podium”。因此,我单击该项目并将其粘贴到文本框中。编辑拼写后,我单击“修改”按钮。现在我想要修改dat项后的焦点。
void btnModify_Click(object sender, EventArgs e)
{
    // change the item...

    // focus the list view
    listView1.Select();
}