I'm looking to add items on a listbox on form A from class B which is called from form A. I just don't know how to say add them to the listbox on the active form A from the class B!?
It's in C#, can anyone help?
It's in C#, can anyone help?
Public Class Form1 Public Shared Sub additemtolistbox(ByVal itemtoadd As String) Form1.ListBox1.Items.Add(itemtoadd) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click myotherclass.subfromotherclasstoadditems() End Sub End Class Public Class myotherclass Public Shared Sub subfromotherclasstoadditems() Form1.additemtolistbox("test") End Sub End Class
public string[] getList() { DBConnect(); string[] list = new string[100]; int i = 0; QueryString = "SELECT title FROM listdat ORDER BY title ASC"; command.CommandText = QueryString; Reader = command.ExecuteReader(); while (Reader.Read()) { list[i] = Reader.GetValue(0).ToString(); i++; } DBDisconnect(); return list; }
Comment