Results 1 to 3 of 3

Thread: Listbox1 to Listbox2

  1. #1
    Join Date
    Jul 2004

    Listbox1 to Listbox2

    How would I take results from a database and make them into ListItems for a listbox?

    I'm trying to populate listbox1 with e-mails and then using a button to add a single value(at a time) to listbox2. In other words, listbox1 will have all the e-mails from the database and listbox2 will have only the e-mails that will get an e-mail. I can populate listbox1 with the database results, it just won't let me add any values to listbox2 from there. I'm thinking that it doesn't know the index value.

  2. #2
    Join Date
    Jul 2004

    Here's my code

    Dim conPubs As SqlConnection
    Dim cmdSelectAuthors As SqlCommand
    Dim dtrAuthors As SqlDataReader
    conPubs = New SqlConnection(ConfigurationSettings.appSettings("STDConnect"))
    cmdSelectAuthors = New SqlCommand("Select * from Email", conPubs)
    dtrAuthors = cmdSelectAuthors.ExecuteReader()
    While dtrAuthors.Read()
    End While

    Now, this works. It populates my listbox with the e-mails. The problem I'm having is not being able to add an e-mail from this listbox into listbox2 by highlighting and submitting a value. Any ideas?

  3. #3
    Join Date
    Jul 2004
    Here is how to add the selected item from ListBox1 to ListBox2:

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        End Sub
    Hope that helps..

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles