?
Solved

Displaying *lots* of lines in a WinForm, possible display objects?

Posted on 2005-04-19
10
Medium Priority
?
270 Views
Last Modified: 2010-04-16
Hullo,

Here's the problem:
I have a text file (could be anywhere from 40 lines to 200,000+) - I can't change this at the moment, this is what I have. The file is a collection of rows of information, sometimes multiple lines per entry for example:

-----------------------------------------------------------
12/04/2005 » 12:00:00 » UserX » FirstLineX
SecondLineX
      ThirdLineX
12/04/2005 » 12:00:01 » UserX » FirstLineY
12/04/2005 » 12:00:02 » UserX » FirstLineZ
-----------------------------------------------------------
etc.

Currently I have this parsed and stored as a dictionary of 'Log' objects, each containing date/time, user, and 'comment' keyed by line numbers. So in the above file I would have 3 entries. This takes about 3-4 seconds for 100,000 lines which is acceptable in my current usage. The next step is to display this data in a WinForm, in a way that will allow me to perform certain tasks:

-----------------------------------------------------------
1) Highlight a row
      - By ForeColour, BackColour & FontStyle (Bold etc), based on the Date, Time, User, and Comment.
2) Filter the rows
      - Again By Date, Time, User, and Comment (e.g. so I can only see all comments made by UserX).
3) Reset the Filters / Highlights
      - So it will show the whole log without any filters etc at all.
4) Double click on a row
      - To launch another form with more detailed information about the row.
5) Accept a Live feed and respond at the same speed.
      - I can connect to a live feed for these logs, infact that's where this program will become most important. So the display will need to be able to update as quickly as the comments come in, this could be 3-4 a second up to 800 a second (maybe more).
-----------------------------------------------------------

Currently I use a ListView, which works fine up to a certain point, but takes the best part of a lifetime to actually load the logs into the display. The listview also allows me to do all 4 of the above tasks, either by editing the properties on a ListViewItem, or adding a 'LogObject' to the Tag property for display purposes (task 4), it can also handle a fair rate of commenting through the Live feed, though I have yet to test on speeds of 800+/sec - I suspect it might not cope so well.

So brief recap for those who have read all this, and for those who skipped straight to the end looking for the point; I want a WinForms component/object that can handle 800+ entries a second, and will allow me to filter/unfilter as quickly as possible, display load times must be as quick as possible (maybe via Lazy Loading?), and must be able to allow highlighting etc.

Any suggestions greatly appreciated.

Ask if you want more information!

Cheers

Wint.
0
Comment
Question by:WinterMuteUK
  • 4
  • 4
  • 2
10 Comments
 
LVL 3

Accepted Solution

by:
mpf1748 earned 1000 total points
ID: 13815251
Have you tried using the ListView's BeginUpdate and EndUpdate? The loading of a list box should be extremely fast if you don't try to redraw the listbox for each record added, which I suspect is the bottleneck in your scenario. I've dropped load times from 10's of seconds to mere seconds on about 1000 lines.
0
 
LVL 9

Author Comment

by:WinterMuteUK
ID: 13815369
I wasn't aware of that, however changing it so it did use it, whilst it appeared to have a small increase in performance hasn't given me the increase I'm really after!
0
 
LVL 3

Expert Comment

by:mpf1748
ID: 13816627
Hmmm...Thats strange. I would imagine though the ListView would perform as good as about any control. You might verify that the the Sorting property of the ListView is set to SortOrder.None.

You might try the ListBox and see what kind of load times you get with that. I don't believe, without looking at it anyway, that you can do all the fancy formatting things that you want to do with it though. Now that I think about it, I think the ListBox is the control I noticed the imporovement on.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 9

Author Comment

by:WinterMuteUK
ID: 13816802
Yes the ListBox won't allow the formatting I'm after, and the sorting is set to none... The problem in speed may also be related to the creation of ListViewItems and the subItems, I'm currently doing some experimenting with that and hope to get it faster! As the speed increase using Begin/End Update was minimal, I guess the problem may actually lie in the processing before adding it to the listview.

Another thing is that I could be looking at files that are 100,000 lines long and this takes a long time to get loaded in.
0
 
LVL 3

Expert Comment

by:mpf1748
ID: 13818244
How long does say Word or another word processor take to load the same text file? If you're talking 100k lines, then thats a lot of data. There probably is more overhead with the creation of the ListViewItems and the formatting and stuff. Sorry I couldn't be of more help.
0
 
LVL 3

Assisted Solution

by:solublefish
solublefish earned 1000 total points
ID: 13820222
Have you tried using the System.Data objects along with the ListViews DataBinding property? This sounds to me a lot like a database application only without the database.

If you can dump your parsed objects efficiently into a DataTable, you can easily use DataView objects for your filters.

And the DataBinding feature of most .NET controls is typcially pretty efficient at displaying. It may have some smarts that prevent if from having to refresh everything on every update.
0
 
LVL 3

Expert Comment

by:solublefish
ID: 13820273
This page has some examples and discussion of data-bound listviews http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadvnet/html/vbnet08262002.asp
0
 
LVL 9

Author Comment

by:WinterMuteUK
ID: 13822295
mpf:
Word takes a little while, but the actual reading of the data isn't so much the problem, for example it takes about 6 seconds to read in 116,000 lines and convert those lines to ListViewItems. But then takes 32 seconds to display it. This is one of the reasons i'm quite interested in a way to lazily load the ListView as that might provide a quicker alternative!

soluble:
I haven't tried the Data objects, I'll give it a go now, and yes, you're right it's very much a DB app, without the DB, (Though with any luck in the next few weeks it will become a DB). I'll have a look at that page and see how I can convert to data tables!

Thanks guys!

Wint.
0
 
LVL 3

Expert Comment

by:mpf1748
ID: 13826093
32 seconds to load 116k lines doesn't sound too bad. You're talking about 3625 lines/second.

You could load the first 1000+ lines and then spawn a thread to load the rest. Be sure and do the Begin/EndUpdate methods. This way the user could see more than enough lines of code "instantly" for the rest to load in the next 30 seconds. You could also do a Begin/EndUpdate for every 1000 lines if you wanted to. This would add overall time, but if it was background time the user probably wouldn't notice.
0
 
LVL 9

Author Comment

by:WinterMuteUK
ID: 13833012
It's something along those lines I am looking at, I'm looking now to lazily load the listview, so if the user scrolls to the top then the previous 'x' lines will be loaded in.

I'm going to split the points as both of you have been very helpful in this problem, the 'DataViews' will be useful as soon as I get the datasets displaying the correct data, and I didn't even know about the Begin/End update stuff before.

Thanks again guys!

Wint.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Screencast - Getting to Know the Pipeline
Suggested Courses

862 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