Items.add for Listbox in VB.Net
I am sure this is a simple question but the solution continues to elude this newbie. I want to add an item to a listbox on one form from another form. Items.add works fine from within the form, but I can't get it to work from another form or a module. help!
Steve
# 1 Re: Items.add for Listbox in VB.Net
The simplest way is to change the ListBox declaration to Public. Then you can do:
FormName.ListBoxName.Items.Add
A cleaner solution, however, is to add a Public method to the form containing the ListBox:
Public Sub AddListBoxItem(Item As Object)
ListBoxName.Items.Add(Item)
End Sub
and call this method from the other form.