Solved

listview just displaying four items

Posted on 2013-06-03
5
357 Views
Last Modified: 2013-06-04
Hi,

I have a listview which should be displaying all the records from the database.  But it keeps displaying only 4 records that too recently added. it ignores all the previous items.  Any idea how to resolve this?

HEre is the code for it.
  Try
         
            If d.ditems.Count > 0 Then


             
                Dim foo As String
                Dim foo1() As String
                Dim item As ListViewItem
                lvfoo.Items.Clear()
                'For Each foo In d.ditems
         
                    foo1 = foo.Split("|")
                    item = New ListViewItem(foo(0))
                    Me..Items.Add(item)
                    item.SubItems.Add(foo(1))
                    item.SubItems.Addfoo(2))

                    'item = Nothing
                Next
            End If
        Catch ex As Exception
            SystemException(ex.ToString)
        End Try

Open in new window

0
Comment
Question by:developer2012
[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
  • 2
5 Comments
 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 39218122
Hi,

Can you check the value of d.ditems.Count? How do you populate the items in d.ditems.count?
0
 

Author Comment

by:developer2012
ID: 39218136
I am populating the values from database.
0
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 39218204
the ode u posted is not compiled and also has a logic error in it.
i assume d.ditems contains the data from database?
did u debug the code and check how many records are they?
u can using linq, to add the records to the listview without iterating the items:
  Try
         
            If d.ditems.Count > 0 Then

                lvfoo.Items.Clear()
        Dim items As ListViewItem() = d.ditems.Select(Function(item) New ListViewItem(item.Split("|").ToArray))
        lvfoo.Items.AddRange(items)
            End If
        Catch ex As Exception
            SystemException(ex.ToString)
        End Try

Open in new window

0
 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 39218366
Can you show us the code on how you populate the d.ditems?
0
 

Author Comment

by:developer2012
ID: 39219077
Fixed.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

738 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