Solved

listview just displaying four items

Posted on 2013-06-03
5
364 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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

734 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