473,544 Members | 1,822 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Time-consuming ListView adding

Hi all, I have following problem: I'm creating a ListView (Details) control
at run-time and filling it with some records (let's say 10 000). This
operation seems to be quite fast, but when I call Controls[x].Add(list),
where list is my ListView control, then program hangs for minute. It seems
like this time depends on number of records added to control. So probably
when adding control to my form, those records are actualy added at this time
(not when calling ListView.Items. Add)... However, does anybody know the way
how to avoid this hanging ? I've tried to put all records adding loop to
background worker, but it gave no effects as they are really added when
adding control to the form. Help.Thanks.
Dec 1 '06 #1
9 4467
Are you doing listView1.Begin Update() before doing the massive add and
EndUpdate() afterward? That should speed it up by telling it not to update
the screen every time you add a data item.

"Kadett" <ka****@cons.pl wrote in message
news:OH******** ******@TK2MSFTN GP02.phx.gbl...
Hi all, I have following problem: I'm creating a ListView (Details)
control at run-time and filling it with some records (let's say 10 000).
This operation seems to be quite fast, but when I call
Controls[x].Add(list), where list is my ListView control, then program
hangs for minute. It seems like this time depends on number of records
added to control. So probably when adding control to my form, those
records are actualy added at this time (not when calling
ListView.Items. Add)... However, does anybody know the way how to avoid
this hanging ? I've tried to put all records adding loop to background
worker, but it gave no effects as they are really added when adding
control to the form. Help.Thanks.

Dec 1 '06 #2
I'm not sure that is an issue. My reading of the OP is that the
ListViewItems are being added to the ListView before the ListView is added
to the Controls collection. Why one would do it that way escapes me as does
why one would want to add 10,000 items - the human brain just can't be able
to cope with that much information.

If the ListView was added to the Controls collection and then filled then
certainly use of the BeginUpdate and EndUpdate methods should be beneficial.

There are a lot of factors here, which we have been made privvy to, like how
much data there is in a single ListViewItem, how efficient is the code that
is creating each ListViewItem etc.

That said, in dealing with 10,000 ListViewItems, there is going to some sort
of bottleneck somewhere.

Perhaps the OP might like to post the PERTINENT code fragments.
"Michael A. Covington" <lo**@ai.uga.ed u.for.addresswr ote in message
news:OZ******** ******@TK2MSFTN GP04.phx.gbl...
Are you doing listView1.Begin Update() before doing the massive add and
EndUpdate() afterward? That should speed it up by telling it not to
update the screen every time you add a data item.

"Kadett" <ka****@cons.pl wrote in message
news:OH******** ******@TK2MSFTN GP02.phx.gbl...
>Hi all, I have following problem: I'm creating a ListView (Details)
control at run-time and filling it with some records (let's say 10 000).
This operation seems to be quite fast, but when I call
Controls[x].Add(list), where list is my ListView control, then program
hangs for minute. It seems like this time depends on number of records
added to control. So probably when adding control to my form, those
records are actualy added at this time (not when calling
ListView.Items .Add)... However, does anybody know the way how to avoid
this hanging ? I've tried to put all records adding loop to background
worker, but it gave no effects as they are really added when adding
control to the form. Help.Thanks.


Dec 1 '06 #3
Sooner or later the .NET control will have to move its data into a Windows
Control. I am guessing that the delay you are experiencing is due to the
underlying windows control being populated from your list.

Have you tried adding the listbox to the form before you start adding items,
and using BeginUpdate/EndUpdate as the previous poster recommended. If the
control is clever (I have no idea) it might give you better run-time
behaviour (not necessarily faster, but you might be able to control it
better).

And, for what it's worth, a listview is entirely inappropriate for
presenting 10,000 items, despite it being capable of doing it. You probably
need a search facility.

"Kadett" <ka****@cons.pl wrote in message
news:OH******** ******@TK2MSFTN GP02.phx.gbl...
Hi all, I have following problem: I'm creating a ListView (Details)
control at run-time and filling it with some records (let's say 10 000).
This operation seems to be quite fast, but when I call
Controls[x].Add(list), where list is my ListView control, then program
hangs for minute. It seems like this time depends on number of records
added to control. So probably when adding control to my form, those
records are actualy added at this time (not when calling
ListView.Items. Add)... However, does anybody know the way how to avoid
this hanging ? I've tried to put all records adding loop to background
worker, but it gave no effects as they are really added when adding
control to the form. Help.Thanks.

Dec 1 '06 #4

"Stephany Young" <noone@localhos twrote in message
news:uG******** ******@TK2MSFTN GP05.phx.gbl...
I'm not sure that is an issue. My reading of the OP is that the
ListViewItems are being added to the ListView before the ListView is added
to the Controls collection. Why one would do it that way escapes me as
does why one would want to add 10,000 items - the human brain just can't
be able to cope with that much information.
Yes. I wonder what it is like to use a ListView with 10,000 items in it.
It may be well beyond some practical size limit that the implementors had in
mind.
Dec 1 '06 #5
I'm not sure that is an issue. My reading of the OP is that the
ListViewItems are being added to the ListView before the ListView is added
to the Controls collection.
That's right. We read some data from particular file and show them in
table-like form. We don't know how many records there will be, as we don't
know how big is source file... However - of course there's possibility of
putting data to the contorl in parts. But it means creating some new methods
just for handling user events (key down, move slider, etc). Yes, maybe I'm
lazy, I did it while programming in VC++, but I've hoped C# would do this
for me :) Anyway thank you for any suggestions, they are precious as always.
Dec 1 '06 #6
Instead of a listview, you might consider inserting the data into a
DataTable and then binding that DataTbale to a DataGridView. A DataGridView
is designed for that sort of thing.
"Kadett" <ka****@cons.pl wrote in message
news:OK******** ******@TK2MSFTN GP05.phx.gbl...
>
>I'm not sure that is an issue. My reading of the OP is that the
ListViewItem s are being added to the ListView before the ListView is
added to the Controls collection.

That's right. We read some data from particular file and show them in
table-like form. We don't know how many records there will be, as we don't
know how big is source file... However - of course there's possibility of
putting data to the contorl in parts. But it means creating some new
methods just for handling user events (key down, move slider, etc). Yes,
maybe I'm lazy, I did it while programming in VC++, but I've hoped C#
would do this for me :) Anyway thank you for any suggestions, they are
precious as always.

Dec 1 '06 #7

U¿ytkownik "Kevin Frey" <ke**********@h otmail.comnapis a³ w wiadomo¶ci
news:ez******** ******@TK2MSFTN GP06.phx.gbl...
Have you tried adding the listbox to the form before you start adding
items, and using BeginUpdate/EndUpdate as the previous poster recommended.
If the control is clever (I have no idea) it might give you better
run-time behaviour (not necessarily faster, but you might be able to
control it better).
That is some idea - it probably won't be faster but I can try to display
some progress information meanwhile...
>
And, for what it's worth, a listview is entirely inappropriate for
presenting 10,000 items, despite it being capable of doing it. You
probably need a search facility.
Ye, I know that - but this is forensic software so I have to display alll
the information I can provide. If user will want to get some choosen part -
then he can do some filter/search operation, but at the start he need to
have all the records...

Thank you.
Dec 1 '06 #8

Peter wrote:
I'd still recommend that you employ some sort of select filter at the
beginning, such as get all the items starting with "A", or "H", etc. Surely
the user has some idea which part of the data they will want to look through
at the beginning?
10,000 rows in a listView or in any other control is overkill.
Peter
Now I'm interested, as we do exactly the same thing... with about
50,000 items.

Our situation is that this is a pick list: the user chooses which item
they want to work with. We use a list view because we want to display
two or three pieces of information about each item: stock code and a
couple of item descriptions.

We created a search (text) box below that allows the user to type a
partial stock code and the list view seeks to the first code starting
with the letters they have typed. When they find the entry they want,
they click on it and this populates a detail screen with information.

And yes, it takes a long time to populate the list view.

The problem is how to provide the user with a reasonable way to choose
from amongst 50,000 items without creating some hokey interface that
requires a lot of interaction.

And no, in this case a search facility is inappropriate because they're
not searching on attributes, they're searching on a code. Populating
the list view as they type the code was also problematic, as in my
earlier experiments the round trips to the database as they typed each
character were just too slow.

Dec 1 '06 #9
What I was suggesting was more of a Typeahead / AutosuggestBox type of
arrangment where the first say, 2 or 3 letters typed into the search Textbox
(using say the Keyup event) cause a call to the (database) with those letters
comprising a SQL WHERE CLAUSE -- WHERE XYZ LIKE 'abc%'
which would return a much more manageable subset that immediately populates
the ListView (or whatever display control it is).
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Bruce Wood" wrote:
>
Peter wrote:
I'd still recommend that you employ some sort of select filter at the
beginning, such as get all the items starting with "A", or "H", etc. Surely
the user has some idea which part of the data they will want to look through
at the beginning?
10,000 rows in a listView or in any other control is overkill.
Peter

Now I'm interested, as we do exactly the same thing... with about
50,000 items.

Our situation is that this is a pick list: the user chooses which item
they want to work with. We use a list view because we want to display
two or three pieces of information about each item: stock code and a
couple of item descriptions.

We created a search (text) box below that allows the user to type a
partial stock code and the list view seeks to the first code starting
with the letters they have typed. When they find the entry they want,
they click on it and this populates a detail screen with information.

And yes, it takes a long time to populate the list view.

The problem is how to provide the user with a reasonable way to choose
from amongst 50,000 items without creating some hokey interface that
requires a lot of interaction.

And no, in this case a search facility is inappropriate because they're
not searching on attributes, they're searching on a code. Populating
the list view as they type the code was also problematic, as in my
earlier experiments the round trips to the database as they typed each
character were just too slow.

Dec 1 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
11653
by: dan glenn | last post by:
Say, I want to set a cookie and have it expire an hour after it's set. It's looking like this is only possible for browsers which are in the same time zone as my server?? In other words, if I set my cookie with: setcookie('CookieName', $SomeValue, time()+3600, "/");
2
11087
by: Ivan | last post by:
Hi, let's say that my server time is for some reason incorrect! Is there a php function that would automaticly correct that time (give or take a few minutes, hours, days...) so date() function would return real time/date!! Thanks, Ivan --
10
4717
by: Yang Li Ke | last post by:
Hi guys, Im about to build a script which will log visitor time spent on my website. I got a few ideas about this, maybe checking visitors ip and storing that info in db with time in and then using session vars to check time out ... Anyone has any ideas about doing that kind of script? Thank you! -- Yang
1
4680
by: Bathroom_Monkey | last post by:
I've got a newb question about Daylight Savings Time (DST). First of all here is some server info: Apache 1.3.28 PHP 4.3.6 MySQL 3.23.49 Time is set to GMT My goal is to be able to accurately record website visits according to my local time (U.S. Central) every day of the year, no matter if I am
3
3652
by: Bathroom_Monkey | last post by:
For posterity's sake, here is an algorithm I created to take a GMT time and convert it to U.S. central time, accounting for daylight saving time. Note: this algorithm can be modified to work for any other U.S. timezone by changing the number of second subtracted at the end. <? $in_dst="false";
4
3845
by: Brian | last post by:
I have 4 sites sharing an account on a server that is in the US Eastern time zone. 3 of those sites are for businesses/persons who live in the same time zone, but one is for a restaurant in the US Pacific time zone. For that site, I want to generate content via a script depending on the local Pacific time and day of week. The content will...
7
4637
by: Valiz | last post by:
Hi, I am updating system time with IRIG time source which sends irregular pulses as shown below 11000011111100111111111111111111....(1-IRIG present and 0-IRIG not present) I need to update system time when I find a steady pulse or a series of 1's say for a span of 10-15 seconds. Is there a way to implement this in VB6? Thanks in advance....
5
23825
by: Hank | last post by:
hi, i have a string as follows 18Nov2003:18:23:43:405 Is there an easy way to convert that to absolute time? What i really want to do is to parse these times from a log file and do time comparisons, averages, stop minus start (elapsed).
6
2840
by: Rebecca Smith | last post by:
Today’s question involves two time text boxes each set to a different time zone. Initially txtCurrentTime will be set to Pacific Time or system time. This will change with system time as we travel across the country. txtRaceTime will always be set to Central Time regardless of where we are in the US. At first I tried ‘Now() – “xx:xx:xx” but...
3
2017
by: cj | last post by:
If I want to check to see if it's after "11:36 pm" what would I write? I'm sure it's easy but I'm getting tired of having to work with dates and times. Sometimes I just want time or date. And to be able to do comparisons on them.
0
7437
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7625
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7389
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7717
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4930
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3427
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
993
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
677
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.