Solved

DatarowView in ListBox not always displayed correctly

Posted on 2004-04-23
3
226 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
[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
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

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