PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms ListView and performance

Reply

ListView and performance

 
Thread Tools Rate Thread
Old 25-06-2003, 04:18 PM   #1
Troy Hilbert
Guest
 
Posts: n/a
Default ListView and performance


Here's the deal.

I've got a class which is the root of an object hierarchy. Within this
class I create a private member variable of type Form. In the form class, I
have created a public LoadFile method that reads a text file (960 KB),
creates an array of ListViewItems(~33,000) based on the file and the I add
those items to the ListView via the AddRange method.

I instantiate the form from the root class, no problem.

I call the LoadFile method, although it measures out to ~1.5 seconds, still
no problem (I execute this method from the root class as a new thread, btw)

Back in the root class, I call Form.Show(), big problem. It takes 25
seconds to simply display the form!??!?!!!!? This HAS to do with the
ListView.

Anyone have a tip or suggestion as to how to improve the display speed of
this form?

Best

Troy


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.491 / Virus Database: 290 - Release Date: 6/18/2003


  Reply With Quote
Old 25-06-2003, 05:37 PM   #2
Herfried K. Wagner
Guest
 
Posts: n/a
Default Re: ListView and performance

Hello,

"Troy Hilbert" <thilbert@spamfree.hotmail.com> schrieb:
> I've got a class which is the root of an object hierarchy.
> Within this class I create a private member variable of
> type Form. In the form class, I have created a public
> LoadFile method that reads a text file (960 KB),
> creates an array of ListViewItems(~33,000) based on the


You may want to use a virtual listview:

http://www.vbcity.com/forums/topic.asp?tid=13777

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet


  Reply With Quote
Old 25-06-2003, 08:31 PM   #3
Troy Hilbert
Guest
 
Posts: n/a
Default Re: ListView and performance

Thanks for the suggestion, but I don't think I am at the point where I want
to use non-standard methods to solve the problem. It's always an option
though. I was hoping to find a quick solution. As I said earlier, I fill
the listview very quickly, it's displaying the form that takes all the time.

Best

"Herfried K. Wagner" <hirf.nosp@m.activevb.de> wrote in message
news:eXBZ$B0ODHA.2480@tk2msftngp13.phx.gbl...
> Hello,
>
> "Troy Hilbert" <thilbert@spamfree.hotmail.com> schrieb:
> > I've got a class which is the root of an object hierarchy.
> > Within this class I create a private member variable of
> > type Form. In the form class, I have created a public
> > LoadFile method that reads a text file (960 KB),
> > creates an array of ListViewItems(~33,000) based on the

>
> You may want to use a virtual listview:
>
> http://www.vbcity.com/forums/topic.asp?tid=13777
>
> Regards,
> Herfried K. Wagner
> --
> MVP · VB Classic, VB .NET
> http://www.mvps.org/dotnet
>
>



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.491 / Virus Database: 290 - Release Date: 6/18/2003


  Reply With Quote
Old 26-06-2003, 06:00 AM   #4
Troy Hilbert
Guest
 
Posts: n/a
Default Re: ListView and performance

Another good idea. I really think that I want to display them all due to
the nature of the information (it's a list of news groups). I've tried
several aproaches and think I've found an acceptable (not optimal) level of
performance. The main problem I was having was that the user interface was
unresponsive while I was adding the items. The solution I came up with was
to create a function to wrap the population of the ListView and then create
a new thread to run that function. Viola, the UI became responsive. I've
got it to the point where I can open the file, read all the items,
instantiate an array of type ListViewItem and populate the ListView with
36000 items (no sub items) in ~15-20 seconds.

Thanks for your suggestions.

Best


"Norm Yuan" <noormanyuan@shaw.ca> wrote in message
news:K0rKa.311827$Vi5.8183671@news1.calgary.shaw.ca...
> Painting Listview on screen is a very slow processing, especially when

each
> ListViewItem has many ListViewSubItems.
>
> I used to have a .NET win form app with a ListView to display up to 2000
> items with each item has uo to 10 subitems. It was too slow to paint the
> ListView, then I used DataGrid instead. It was a lot faster.
>
> But, why display 33000 items once? Do you expect user scrolls through all
> these items for what? Better approach would be to use some kind of paging
> display. Say, you load data (33000 records) into an array, or DataTable;
> place 10 buttons beside the ListView with text "1", "2",..."10"; when
> button1 is clicked, the listview displays the first 1000 records, button2
> for 1001 to 2000 records.... Or, you can sort records in alphabetical

order,
> then button "A" for all records beginning with "A..." and so on. This way,
> the display time is shortened and user does not have to scoll through huge
> amount of records.
>
>
> "Troy Hilbert" <thilbert@spamfree.hotmail.com> wrote in message
> news:%23mPjFj1ODHA.1720@TK2MSFTNGP11.phx.gbl...
> > Thanks for the suggestion, but I don't think I am at the point where I

> want
> > to use non-standard methods to solve the problem. It's always an option
> > though. I was hoping to find a quick solution. As I said earlier, I

> fill
> > the listview very quickly, it's displaying the form that takes all the

> time.
> >
> > Best
> >
> > "Herfried K. Wagner" <hirf.nosp@m.activevb.de> wrote in message
> > news:eXBZ$B0ODHA.2480@tk2msftngp13.phx.gbl...
> > > Hello,
> > >
> > > "Troy Hilbert" <thilbert@spamfree.hotmail.com> schrieb:
> > > > I've got a class which is the root of an object hierarchy.
> > > > Within this class I create a private member variable of
> > > > type Form. In the form class, I have created a public
> > > > LoadFile method that reads a text file (960 KB),
> > > > creates an array of ListViewItems(~33,000) based on the
> > >
> > > You may want to use a virtual listview:
> > >
> > > http://www.vbcity.com/forums/topic.asp?tid=13777
> > >
> > > Regards,
> > > Herfried K. Wagner
> > > --
> > > MVP · VB Classic, VB .NET
> > > http://www.mvps.org/dotnet
> > >
> > >

> >
> >
> > ---
> > Outgoing mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.491 / Virus Database: 290 - Release Date: 6/18/2003
> >
> >

>
>



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.491 / Virus Database: 290 - Release Date: 6/18/2003


  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off