Hello,
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!!
Amber
Private Sub butRetrieve_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles butRetrieve.Click
If txtCPMain.Text <> "" Then
get_specific_CP()
Else
get_all_CPs()
End If
End Sub
**
Sub get_specific_CP()
lBoxCP.DataSource = Nothing
lBoxCP.Items.Clear()
lBoxCP.Refresh()
DsCP1.Clear()
SqlDA_CP.Fill(DsCP1)
Dim dtbCP As DataTable
dtbCP = DsCP1.Tables(0)
Dim dtvCP As New DataView(dtbCP)
dtvCP.RowFilter = "STR_CUTTING_PERMIT = '" & txtCPMain.Text & "'"
lBoxCP.DataSource = dtvCP
lBoxCP.DisplayMember = "STR_CUTTING_PERMIT"
fill_all_textfields()
End Sub
**
Private Sub get_all_CPs()
lBoxCP.DataSource = Nothing
lBoxCP.Items.Clear()
lBoxCP.Refresh()
DsCP1.Clear()
SqlDA_CP.Fill(DsCP1)
lBoxCP.DataSource = DsCP1.Tables(0)
lBoxCP.DisplayMember = "STR_CUTTING_PERMIT"
End Sub