Solved

DatarowView in ListBox not always displayed correctly

Posted on 2004-04-23
3
225 Views
Last Modified: 2010-04-24
I have an application where the Datasource of a ListBox is a datatable or a dataview.

Sometimes when the list box is displayed it shows the 5 items correctly, at other time it shows System.Data.DataRowView as the text for each item. How can I ensure that it always shows teh text correctly?

Sub PopulateGlobeList(ByRef r_lst As ListBox)

            Dim oKey(0) As System.Data.DataColumn
            Dim tblGlobe As DataTable

            r_lst.BeginUpdate()

                '  Creat and populate data table
                  .......

                ' Set key and sort info
                oKey(0) = tblGlobe.Columns("GlobeID")
                tblGlobe.PrimaryKey = oKey
                tblGlobe.DefaultView.Sort = "GlobeText"

                ' ---- and bind to the the list box
                r_lst.DataSource = tblGlobe.DefaultView
                r_lst.ValueMember = "GlobeID"
                r_lst.DisplayMember = "GlobeText"

            r_lst.EndUpdate()

End Sub
0
Comment
Question by:WhiteEagle
3 Comments
 
LVL 3

Accepted Solution

by:
Lektran earned 50 total points
ID: 10907041
the only time i have that problem occur is if i have not yet set the displaymember property or if i have set it incorrectly
it might pay to spend some time testing to see what is different when the list displays correctly and incorrectly

p.s im pretty sure you dont need to include the DefaultView part of your datasource you should find that the data will display as sorted without it
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

730 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