Results 1 to 10 of 10

Thread: [2008] Refreshing my Datagriview without having Flickering.

  1. #1

    Thread Starter
    Hyperactive Member shyguyjeff's Avatar
    Join Date
    Jul 2007
    Location
    City of Durian
    Posts
    289

    [2008] Refreshing my Datagriview without having Flickering.

    Elow everyone, it's me again. Could anyone tell me how to refresh my datagrid without having flickering on my datagridview. My program is like this, I have a program and in every tick of the timer i load my data on the datagrid so that my data on the datagrid is updated from my server but my problem is that it flickers when i put it on the timer tick and it not presentable to the viewer when it flickers. Could anyone tell me how to do that without flickering but my data is updated always from the server? Thanks in advance guys..
    Last edited by shyguyjeff; May 28th, 2008 at 12:55 AM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] Refreshing my Datagriview without having Flickering.

    What exactly are you doing at the moment?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member shyguyjeff's Avatar
    Join Date
    Jul 2007
    Location
    City of Durian
    Posts
    289

    Re: [2008] Refreshing my Datagriview without having Flickering.

    Every tick of the time I load my data on my datagrid so that on my datagrid it is updated from the server but my problem jm is that if i put on the timer tick it flickers and it is not comfortable to viewers. So what I want is that is there any possible ways so that it will not flicker jm?

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] Refreshing my Datagriview without having Flickering.

    Quote Originally Posted by jmcilhinney
    What exactly are you doing at the moment?
    i.e. what code are you executing?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Hyperactive Member shyguyjeff's Avatar
    Join Date
    Jul 2007
    Location
    City of Durian
    Posts
    289

    Re: [2008] Refreshing my Datagriview without having Flickering.

    On my Getdata jm here it goes.

    Code:
     Private Sub GetData()
            Try
             
                Dim connStr As String = "Server=myServer;Database=myDatabase;Trusted_Connection=True;"
                Dim myQuery As String = "SELECT * form customer"
    
                Dim myConnection As SqlConnection = New SqlConnection(connStr)
                Dim myCommand As SqlCommand = New SqlCommand(myQuery, myConnection)
                Dim myAdapter As SqlDataAdapter = New SqlDataAdapter(myCommand)
                Dim myDataset As DataSet = New DataSet("SalesMonitor")
                Dim myDataTable As New DataTable
             
    
                myConnection.Open()
    
                myAdapter.Fill(myDataset, "SalesMonitor")
                DataGridView1.DataSource = myDataset.Tables("SalesMonitor")
    
    
                myConnection.Close()
    
    
                   Catch ex As Exception
    
                MessageBox.Show(ex.Message)
    
            End Try
    
        End Sub
    Then I put that get data on my Timer tick jm.
    Code:
     Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            Label3.Text = FormatDateTime(Now, DateFormat.LongDate)
            Label3.Text = TimeOfDay
            GetData()
        End Sub

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] Refreshing my Datagriview without having Flickering.

    I saw another thread where you were asking about doing this on a background thread. Are you going to do that?

    You might also try calling SuspendLayout and ResumeLayout on the grid, although i'm not sure whether it will have an effect. You might also try setting the DataSource to Nothing before assigning the table. In theory it shouldn't matter but it is worth a go.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Hyperactive Member shyguyjeff's Avatar
    Join Date
    Jul 2007
    Location
    City of Durian
    Posts
    289

    Re: [2008] Refreshing my Datagriview without having Flickering.

    Quote Originally Posted by jmcilhinney
    I saw another thread where you were asking about doing this on a background thread. Are you going to do that?

    You might also try calling SuspendLayout and ResumeLayout on the grid, although i'm not sure whether it will have an effect. You might also try setting the DataSource to Nothing before assigning the table. In theory it shouldn't matter but it is worth a go.
    Yes jm i try to work it on background but i could not catch up the actual background thread. hmmmmp..SuspendLayout and ResumeLayout jm? I will try that one. What if i work it on my background jm? How can I do that? I have here my code but it does not work thats why i ask if there is any ways aside from that. Thanks jm again..

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] Refreshing my Datagriview without having Flickering.

    You can check out my BackgroundWorker thread for a code example. In your case you'd use the pattern where the UI gets updated from the RunWorkerCompleted event handler, which is in post #4. The DataTable would be the e.Result.

    Also, don't use a DataSet. It serves no purpose. Just use a DataTable.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    Hyperactive Member shyguyjeff's Avatar
    Join Date
    Jul 2007
    Location
    City of Durian
    Posts
    289

    Re: [2008] Refreshing my Datagriview without having Flickering.

    Thanks jm..I will try to..Your really a great and kind...I wish i could be like you someday.. Thank you very much jm..

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] Refreshing my Datagriview without having Flickering.

    Quote Originally Posted by shyguyjeff
    I wish i could be like you someday..
    Be careful what you wish for. Oh, the smell...
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width