By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,960 Members | 2,232 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,960 IT Pros & Developers. It's quick & easy.

DGV refresh/update

P: 31
Does anyone know how to stop a datagridview from either stopping the display update or to slow down the refresh rate on it?

I have a lot of data I would like to display but I only want it to update like once a second or something.

dgv1.datasource = myDT;

is updating every time the datable updates.

TIA
Aug 10 '10 #1
Share this Question
Share on Google+
5 Replies


Aimee Bailey
Expert 100+
P: 197
Simple answer, DGV is very good at managing what is shown so i would stay away from trying to interfere with that, instead, what i'd reccomend is seeing weather the datatable in the background really needs to update so often, instead maybe have a second datatable that works as a snapshot for what you are looking at, then use that second one as the datasource.

Only an idea, but i promise it's worth looking into :)

Aimee.
Aug 10 '10 #2

P: 31
Aimee, thank you for your reply.

Are you suggesting something like this:

Expand|Select|Wrap|Line Numbers
  1.  //class variables
  2.         DateTime uTime = DateTime.Now;
  3.         double mySecCheck;
  4.         DataTable dt1;
  5.         DataTable dt2;
  6.  
  7.         private void procDGVTimer()
  8.         {
  9.  
  10.             DateTime eTime = DateTime.Now;
  11.             TimeSpan dSpan = eTime - uTime;
  12.  
  13.             mySecCheck = dSpan.Seconds + (dSpan.Minutes * 60);
  14.  
  15.             if (mySecCheck > 1)
  16.             {
  17.  
  18.                 dt2 = dt1.Clone();
  19.                 dgv1.DataSource = dt2;
  20.                 utime = DateTime.Now;
  21.             }
  22.  
Aug 10 '10 #3

Aimee Bailey
Expert 100+
P: 197
Well thats one way to go about it :) may i ask where your data is coming from? is it a database, or something different?

Aimee
Aug 10 '10 #4

P: 31
Aimee,

Ya, I wasn't sure what you were hinting at. From my understanding, if you make a datatable equal to another it creates a pointer. But if I clone, I think that maybe really cpu intensive.


1. Get live data
2. Process in seperate class to create new data.
3. Data is changed in the datatable.

I get data and convert it into something else. I track what row through out and set that row and column in the datagridview datatable.
Aug 10 '10 #5

Aimee Bailey
Expert 100+
P: 197
In the case of an SQL database then, id suggest optimizing your system where it only retrieves the data needed rather than everything. For instance i am currently working on a Gantt package for orders, ive narrowed what i show though by week (this is done in my queries), also to optimize my queries, i try to keep them small where possible, and ordered by column importance. (i.e. indexed ID first).
Aug 10 '10 #6

Post your reply

Sign in to post your reply or Sign up for a free account.