Solved

Real-time Datagrid?

Posted on 2004-04-13
10
362 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 37

Expert Comment

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

Author Comment

by:Crestline
Comment Utility
I don't think you can sort on ever column in a ListView.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 37

Expert Comment

by:gregoryyoung
Comment Utility
you can implement your sort in a dataview
0
 

Author Comment

by:Crestline
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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)…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now