Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Why is my listbox not filling?????

Posted on 2009-05-13
4
Medium Priority
?
268 Views
Last Modified: 2012-08-14
I am missing something, just not sure what.
I am filling a listbox using a dataset.  There is 1 record in the table and when I do message boxes to show if there are any items in the listbox, it shows that there is the 1 item, but the item does not show in the list box.
What am I doing wrong???
Below I use messageboxes to check that there is an item.
Private Sub FillTaskList(Optional ByVal bStartUp As Boolean = False)
        Dim cT As New cTasks(ConnectionString)
 
        cT.FillList(Me.lstTasks)
        MessageBox.Show(Me.lstTasks.Items.Count)
        If bStartUp Then
            cT.SetupTaskLUGrid(Me.fpGrdTasks)
            MessageBox.Show(Me.lstTasks.Items.Count)
            Me.lstTasks.SelectedIndex = -1
            MessageBox.Show(Me.lstTasks.Items.Count)
        End If
    End Sub
 
I fill the list using
Private Function SQLCombo() As String
        Dim str As String
 
        str = "SELECT TaskID, " _
        & " TaskName " _
        & " FROM TasksLU " _
        & " ORDER BY TaskName"
 
        Return str
 
    End Function
 
 
 
 
    Public Sub FillList(ByVal cnt As ListBox)
        Dim ds As New DataSet
 
        If DatabaseToUse() = BizObjs.DBType.Access Then
            'Access Database
            Dim dc As New OleDb.OleDbConnection(ConnectionString)
            Dim da As New OleDb.OleDbDataAdapter(SQLCombo, dc)
 
            Try
 
                da.Fill(ds)
                dc.Close()
                cnt.DataSource = ds.Tables(0)
                cnt.DisplayMember = "TaskName"
                cnt.ValueMember = "TaskID"
 
            Catch ex As Exception
 
                MessageBox.Show(ex.Message)
                ''Throw ex
 
            Finally
                dc.Close()
                da.Dispose()
            End Try
        End If
 
    End Sub

Open in new window

0
Comment
Question by:Sheritlw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
Deathrace earned 1000 total points
ID: 24377378
0
 

Author Comment

by:Sheritlw
ID: 24377450
This is a windows form VB 2008 net app and the listbox does not have a databind property.
Thanks
0
 
LVL 11

Assisted Solution

by:srikanthreddyn143
srikanthreddyn143 earned 1000 total points
ID: 24378054
Try

Public Sub FillList(ByRef cnt As ListBox)
0
 

Author Comment

by:Sheritlw
ID: 24378092
unfortunately that didn't work:-(
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question