473,395 Members | 1,454 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 4457
Are you doing listView1.BeginUpdate() 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.plwrote in message
news:OH**************@TK2MSFTNGP02.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.edu.for.addresswrote in message
news:OZ**************@TK2MSFTNGP04.phx.gbl...
Are you doing listView1.BeginUpdate() 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.plwrote in message
news:OH**************@TK2MSFTNGP02.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.plwrote in message
news:OH**************@TK2MSFTNGP02.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@localhostwrote in message
news:uG**************@TK2MSFTNGP05.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.plwrote in message
news:OK**************@TK2MSFTNGP05.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.

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**********@hotmail.comnapisał w wiadomo¶ci
news:ez**************@TK2MSFTNGP06.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
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...
2
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...
10
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...
1
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...
3
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...
4
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...
7
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...
5
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...
6
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...
3
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...
0
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...
0
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...

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.