Listbox problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • amber

    Listbox problem

    Hello
    I'm not sure if I should give up trying to find an answer here...or just keep posting my problem..

    I'm having problems with a listbox..
    I have a listbox that is populated when a user presses a button (retrieve). There is a textbox on the form, and if the textbox is left blank, and the user presses the button, all records show in the listbox. If the user enters a specific item into the textbox, then presses the button, only that record shows in the listbox. There are fields on the form which are populated by data associated with what is selected in the listbox
    All this works great...my problem is this
    The first time 'retrieve' is clicked, it works great, but then, if something else is entered into the textbox, or it is cleared to retrieve all records, when the button is clicked, the listbox doesn't display it's contents
    The data is there...all fields on the form are filled in correctly, and you can even click on the list box to change what is selected, you just can't see anything in the list box...
    I'm baffled
    I'm pasting my code below
    Sorry this is so lengthy! Thanks in advance!
    Ambe

    Private Sub butRetrieve_Cli ck(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles butRetrieve.Cli c

    If txtCPMain.Text <> "" The

    get_specific_CP (

    Els

    get_all_CPs(

    End I

    End Su

    *

    Sub get_specific_CP (

    lBoxCP.DataSour ce = Nothin

    lBoxCP.Items.Cl ear(

    lBoxCP.Refresh(


    DsCP1.Clear(

    SqlDA_CP.Fill(D sCP1

    Dim dtbCP As DataTabl

    dtbCP = DsCP1.Tables(0

    Dim dtvCP As New DataView(dtbCP

    dtvCP.RowFilter = "STR_CUTTING_PE RMIT = '" & txtCPMain.Text & "'

    lBoxCP.DataSour ce = dtvC

    lBoxCP.DisplayM ember = "STR_CUTTING_PE RMIT

    fill_all_textfi elds(

    End Su

    *

    Private Sub get_all_CPs(

    lBoxCP.DataSour ce = Nothin

    lBoxCP.Items.Cl ear(

    lBoxCP.Refresh(

    DsCP1.Clear(

    SqlDA_CP.Fill(D sCP1

    lBoxCP.DataSour ce = DsCP1.Tables(0

    lBoxCP.DisplayM ember = "STR_CUTTING_PE RMIT

    End Su

Working...