473,378 Members | 1,507 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

listbox problem

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
Nov 20 '05 #1
0 1208

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Brian | last post by:
Hi, All, I'm using MS.net 2003 and using a windows.forms.listbox control for my window application but I don't know why the Horizontal Scrollbar could NOT be shown even if I set...
5
by: Bill | last post by:
I have have two list boxes. One is a listing of all possible variables. We'll call this listbox A. The other is a listing of all the selected variables. We'll call this listbox B. If a person...
2
by: Simon P | last post by:
Hello group, I'm in desperate need of help. Here goes : I have the following tables : CONTACTS (ContactID, FirstName, LastName, Company, etc.), SHOWS (ShowID, ShowDescription) and SHOWDETAILS...
1
by: Josema | last post by:
Hi to all, I have a class (persons) that derives from collection base: and another class (person) with this properties: -ID -Name When i have complete filled the object Persons with all...
1
by: MrNobody | last post by:
Hi, I'm doing something where I add custom objects to a ListBox which have aToString() method overriden so it displays what I want. When adding instances of these custom objects to the ListBox I...
1
by: yamne | last post by:
I have a problem. When I click in edit datagrid button I show two listbox and two button. I use two button to move data between two listbox. My problem is that I can't call the listbox in the...
4
by: Ron | last post by:
I've got a listbox that holds a list of groups. Users can select a group, hit the remove button and the group should be removed from the listbox. The only problem is that no matter which group you...
8
by: nirdeshonline | last post by:
Hi, I have added a simple listbox in windows form under c# 2.0. It contains a collection of approx 10 strings as list items. Now when i resize the form whole listbox flickers. Please tell me...
9
by: zdrakec | last post by:
Hello all: Clearly, I'm not getting it! Here is the scenario: On a web page, I have two list boxen and a text box. The first listbox is populated at page load time (if it is not a postback)....
15
by: Doogie | last post by:
I have a .net app that a user currently enters a number in a text box, hits a button and a data call is executed. She wants the ability to enter in multiple numbers (up to 100). So to make...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.