Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Real-time Datagrid?

Posted on 2004-04-13
10
Medium Priority
?
374 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
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 1500 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

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 …
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

927 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