インデックスを使用してlistView
からアイテムを追加しようとしています。array of strings
以下は私のコードです:
using (StringReader tr = new StringReader(Mystring))
{
string Line;
while ((Line = tr.ReadLine()) != null)
{
string[] temp = Line.Split(' ');
listview1.Items.Add(new ListViewItem(temp[1], temp[3]));
}
}
しかし、それはindex out of bound error
.
インデックスを使わない場合
listview1.Items.Add(new ListViewItem(temp));
正常に動作し、配列の内容を listView に追加します。
また、listView にゼロ インデックス文字列を追加します。1 つ、2 つ、またはその他のインデックスの場合、同じエラーが発生します。
index またはその他の方法を使用して、必要な文字列のみを listView に追加する方法を教えてください。前もって感謝します!