リストボックスへ項目を追加します。
最初にフォーム上にリストボックスListBox1
を用意しています。一つずつ項目を追加する
Me.ListBox1.Items.Add("dog") Me.ListBox1.Items.Add("cat")
高速に項目を追加する
項目を追加する度に発生する描画処理を抑止する事で、高速に項目を追加する事が可能です。
Dim animals() As String = {"dog", "cat"} Me.ListBox1.BeginUpdate() For each animal As String in animals Me.ListBox1.Items.Add(animal) Next animal Me.ListBox1.EndUpdate()
一度に複数の項目を追加する
ListBox.ObjectCollectionクラス、または配列であれば一度に複数の項目を追加出来ます。
Dim animals() As String = {"dog", "cat"} Me.ListBox1.Items.AddRange(animals)