|
-
May 28th, 2008, 12:48 AM
#1
Thread Starter
Hyperactive Member
[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.
-
May 28th, 2008, 12:54 AM
#2
Re: [2008] Refreshing my Datagriview without having Flickering.
What exactly are you doing at the moment?
-
May 28th, 2008, 01:00 AM
#3
Thread Starter
Hyperactive Member
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?
-
May 28th, 2008, 01:04 AM
#4
Re: [2008] Refreshing my Datagriview without having Flickering.
 Originally Posted by jmcilhinney
What exactly are you doing at the moment?
i.e. what code are you executing?
-
May 28th, 2008, 01:12 AM
#5
Thread Starter
Hyperactive Member
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
-
May 28th, 2008, 01:20 AM
#6
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.
-
May 28th, 2008, 01:26 AM
#7
Thread Starter
Hyperactive Member
Re: [2008] Refreshing my Datagriview without having Flickering.
 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..
-
May 28th, 2008, 01:32 AM
#8
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.
-
May 28th, 2008, 01:44 AM
#9
Thread Starter
Hyperactive Member
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..
-
May 28th, 2008, 01:53 AM
#10
Re: [2008] Refreshing my Datagriview without having Flickering.
 Originally Posted by shyguyjeff
I wish i could be like you someday.. 
Be careful what you wish for. Oh, the smell...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|