DGV refresh/update

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • newbtemple
    New Member
    • Feb 2008
    • 31

    DGV refresh/update

    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
  • Aimee Bailey
    Recognized Expert New Member
    • Apr 2010
    • 197

    #2
    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.

    Comment

    • newbtemple
      New Member
      • Feb 2008
      • 31

      #3
      Aimee, thank you for your reply.

      Are you suggesting something like this:

      Code:
       //class variables
              DateTime uTime = DateTime.Now;
              double mySecCheck;
              DataTable dt1;
              DataTable dt2;
      
              private void procDGVTimer()
              {
      
                  DateTime eTime = DateTime.Now;
                  TimeSpan dSpan = eTime - uTime;
      
                  mySecCheck = dSpan.Seconds + (dSpan.Minutes * 60);
      
                  if (mySecCheck > 1)
                  {
      
                      dt2 = dt1.Clone();
                      dgv1.DataSource = dt2;
                      utime = DateTime.Now;
                  }

      Comment

      • Aimee Bailey
        Recognized Expert New Member
        • Apr 2010
        • 197

        #4
        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

        Comment

        • newbtemple
          New Member
          • Feb 2008
          • 31

          #5
          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.

          Comment

          • Aimee Bailey
            Recognized Expert New Member
            • Apr 2010
            • 197

            #6
            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).

            Comment

            Working...