Solved

Real-time Datagrid?

Posted on 2004-04-13
10
366 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
The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

 
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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

828 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