Solved

Real-time Datagrid?

Posted on 2004-04-13
10
364 Views
Last Modified: 2012-06-27
I'm looking for a solution where I would like to present real-time (or almost real-time) data on some kind of grid.  It doesn't necessarily need to be a data grid but it has to be on a Windows form, data needs to be sortable, selectable, etc like a dategrid.  I'd like to update this data very frequently anywhere between 10-30secs.  There will only be a max of 50 rows and in the end maybe 10 columns.

The problem I'm having at the moment is that everytime a row is reviewed and updated (if needed) there is quite a lot of screen flicker as well as if you had a row selected, it looses focus.  I'm using a datatable to prepare the data for the grid and perform all updates on.

If you have any ideas, would love to here them.
0
Comment
Question by:Crestline
  • 6
  • 4
10 Comments
 

Author Comment

by:Crestline
ID: 10817110
Also, I'd like to hand off the updating to nother thread or something so that the interface isn't 'hung up' while the some calculations are being performed on the data that is to update the datatable.  In other words, the user should be able to function as normal and only notice that the grid is being updated, I don't want it to interfere with them using the rest of the application.

0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 10817323
a good interface might be to have the gird being update constantly then you click on a row to open a seperate form for editting ... updates can easily be done in another thread.
0
 

Author Comment

by:Crestline
ID: 10817863
The gird is not updatable by the user, it's for reference only.  All they need/can do is sort, select and double click.

I'll run some more tests this evening again to make sure I do have a problem and haven't over looked anything.  I just don't want the interface to be annoying in regards to a flickering datagraid (from the updates) and a pause in the app while doing calculations.

I don't have a whole lot of experience with grids, etc. and this is kind of the outline of what I've done so far.
-the datagrid's datasource is set to the datatable1
-datatable2 is populated via an XML file read
-comparisons are made between the 2 datatables and datatable1 is updated (row by row) if needed.  In other words, it steps through the rows in datatable2 and if there are changes, it updates/adds rows to datatable1 which in turn updates the visible datagrid

The reason I don't just read the XML file into datatable1 is because of the the repainting/flickering that seems to happen because a clear(); has to be called before the new data is added to datatable1.

I'm sure there is a lot better/efficient way to do this which is why I'm here, asking all of you.  :-)  
 


0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 37

Expert Comment

by:gregoryyoung
ID: 10817894
what about using a ListView and using BeginUpdate() and EndUpdate() to prevent the flicker as you change items ?
0
 

Author Comment

by:Crestline
ID: 10817946
I don't think you can sort on ever column in a ListView.
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 10817957
you can implement your sort in a dataview
0
 

Author Comment

by:Crestline
ID: 10818081
Ok, so I'd have to wrtie some code to take of this on the OnClick event of the column headers.  I went directly to a datagrid and didn't test a dataview which I can do this evening.

Another thing...
When I send a pointer to datatable1 to a seperate thread that loads the xml file into datatable2 and does all the calculations/updating of the datatable1, the performance is pretty bad.  Half the time it blows up the app....  If I run the same code from within the form (no seperate thread), once the calculations are complete and it's time to update, it's quick and there is no flicker.  The problem is the app is held up until it's fnished...

0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 500 total points
ID: 10818139
probably a locking issue ...

send the thread a cloned version to update ...

then have your main thread replace the version it had with the version that the thread worked on (the background thread can invoke a method with the changed data on your form in your forms thread)
0
 

Author Comment

by:Crestline
ID: 10833241
Update...

Clone() copies settings/schema but no data so I'm using Copy().  I found some infomation on a form's MethodInvoker and having success running the calculations on the Copied datatable then copying in it back to dataTable1.  The Update() runs in a thread and then the actual call to reset the datasource has to be called using Invoke (found that out the hard way :-).    It's working good but there is a couple of annoying things like...  when you use a datatables Copy(), it creates a new datatable so you have to reset it as the datasource to the datagrid.  In doing this you loose which column you've sorted by prior to the updates as well as the selection.  Nothing major, just annoying.  I'll keep track of sort order/column and selected row before the update and reset it right after.  Not the best, but it should work.  Still using a datagrid, seems to be ok.



0
 

Author Comment

by:Crestline
ID: 10849051
When I originally post 500pts I was thinking that I would be getting some code examples, which i have figured out for myself.  I'll give you some points but 500 seems a little high.  Is there any way I can knock it down to 200?

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 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