方法 : Windows フォーム ListView コントロールで項目を追加および削除する
Windows フォームの ListView コントロールに項目を追加するには、項目を指定し、その項目にプロパティを割り当てます。 リスト項目の追加または削除は、いつでも実行できます。
プログラムによって項目を追加するには
-
' Adds a new item with ImageIndex 3 ListView1.Items.Add("List item text", 3)
// Adds a new item with ImageIndex 3 listView1.Items.Add("List item text", 3);
プログラムによって項目を削除するには
Items プロパティの RemoveAt メソッドまたは Clear メソッドを使用します。 RemoveAt メソッドは 1 つの項目を削除します。Clear メソッドはリストのすべての項目を削除します。
' Removes the first item in the list. ListView1.Items.RemoveAt(0) ' Clears all items: ListView1.Items.Clear()
// Removes the first item in the list. listView1.Items.RemoveAt(0); // Clears all the items. listView1.Items.Clear();
参照
参照
ListView コントロールの概要 (Windows フォーム)