Solved

Real-time Datagrid?

Posted on 2004-04-13
10
369 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

Create CentOS 7 Newton Packstack Running Keystone

A bug was filed against RDO for the installation of Keystone v3. This guide is designed to walk you through the configuration for using Keystone v3 with Packstack. You will accomplish this using various repos and the Answers file.

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

615 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