2つのリストを表示するC#WinFormsにlistView1があります
List<string> pths;
List<string> rec;
public void Disp ()
        {
            DisplayListInColumns(listView1, pths, 0);
            DisplayListInColumns(listView1, rec, 1);
        }
private static void DisplayListInColumns(ListView listView, List<string> values, int columnIndex)
        {
            for (int index = 0; index < values.Count; index++)
            {
                while (index >= listView.Items.Count)
                {
                    listView.Items.Add(new ListViewItem());
                }
                ListViewItem listViewItem = listView.Items[index];
                while (listViewItem.SubItems.Count <= columnIndex)
                {
                    listViewItem.SubItems.Add(new ListViewItem.ListViewSubItem());
                }
                listViewItem.SubItems[columnIndex].Text = values[index];
            }
        }
グローバル リストを使用して変更を加え、listview1 にも表示しますが、ユーザーが apply_button をクリックした後にのみ、変更が (xml に) 保存されます。
[詳細の編集と追加] ボタンは正常に機能し、完全に表示されています。しかし、データを削除すると、エラーがスローされます。
削除アクションは次のとおりです。
//Configuration - DELETE button
        private void button6_Click(object sender, EventArgs e)
        {
            string select = null;
            if (listView1.SelectedItems.Count > 0)
            {
                select = (listView1.SelectedItems[0].Text);
            }
            int count = listView1.SelectedItems[0].Index;
            if (select != null)
            {
                pths.RemoveAt(count);
                rec.RemoveAt(count);
                string s = String.Join("; ", pths.ToArray());
                string r = String.Join("; ", rec.ToArray());
                //MessageBox.Show(s);
                //MessageBox.Show(r);                                
            }
            Disp();
        }
数回試行した後、インデックスに問題があると思います。削除した後でも、デバッグ中にlistView.Items.Count = 5. 
、カウントがまだ 5 (サンプル - リスト内の 5 文字列) であると推測していますが、削除後は 4 に減少し、それに応じてインデックス 0-3 になります。次のエラーが表示されます
ArgumentOutOfRangeException at pths.RemoveAt(count)
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
代わりに試してみpths.Remove(select);ましたが、これは解決しませんでした。
どんな助けでも大歓迎です。ありがとうございました