C# 带有箭头键的listview导航无法正常工作

C# 带有箭头键的listview导航无法正常工作,c#,.net,listview,C#,.net,Listview,我有以下代码,当按下控件(按钮1)时,它选择listview中的下一项。如果我单击按钮1转到下一个项目,它将工作,但所选项目不同步。要测试这一点,只需单击按钮几次,然后按键盘上的向上或向下键。它不会像应该的那样转到上一个/下一个项目 有人遇到过这个问题吗?我错过了什么 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawin

我有以下代码,当按下控件(按钮1)时,它选择listview中的下一项。如果我单击按钮1转到下一个项目,它将工作,但所选项目不同步。要测试这一点,只需单击按钮几次,然后按键盘上的向上或向下键。它不会像应该的那样转到上一个/下一个项目

有人遇到过这个问题吗?我错过了什么

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace lv_issue
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            listView1.Items[0].Selected = true;
        }

        private void button1_Click(object sender, EventArgs e)
        {

            if (listView1.SelectedItems.Count == 0)
                return;
            listView1.Focus();

            int s = listView1.SelectedItems[0].Index;

            listView1.Items[s].Selected = false;

            if (s < listView1.Items.Count - 1)
                s++;

            listView1.SelectedItems.Clear();
            listView1.Items[s].Selected = true;

        }
    }
}
使用系统;
使用System.Collections.Generic;
使用系统组件模型;
使用系统数据;
使用系统图;
使用System.Linq;
使用系统文本;
使用System.Threading.Tasks;
使用System.Windows.Forms;
名称空间LVU问题
{
公共部分类Form1:Form
{
公共表格1()
{
初始化组件();
listView1.Items[0]。Selected=true;
}
私有无效按钮1\u单击(对象发送者,事件参数e)
{
如果(listView1.SelectedItems.Count==0)
返回;
listView1.Focus();
int s=listView1.SelectedItems[0]。索引;
listView1.Items[s].Selected=false;
如果(s
找到了解决方案-除了上述代码之外,还需要使用

listview1.Items[s].Focused=true;
然后一切都按它应该的方式进行