[RESOLVED] DataGridView and Timer
i have a datagridview binded with the datatable via its datasource property....
now i want to add the Amount column of the dgv and display the total amount in the textbox,if the amount is greater than a certain value then i want the cell to coloured red
so i did this code and it worked great:
Code:
Dim i, j As Integer
For i = 0 To DataGridView1.RowCount - 1
j += Me.DataGridView1.Rows(i).Cells("Amount").Value
Next
If j > 150 Then
Me.DataGridView1.Rows(2).Cells("Amount").Style.BackColor = Color.Red
End If
TextBox1.Text = j.ToString
but my problem is that i want the red colour of the cell to blinkafter every 2 seconds....how to do this?
i need to handle the timer tick event for this but i am not able to do this.....
please help......
thank you
Re: DataGridView and Timer
Hi,
Add a timer and set the interval 2000, then try something like this:
Code:
Dim i, j As Integer
For i = 0 To DataGridView1.RowCount - 1
j += Me.DataGridView1.Rows(i).Cells("Amount").Value
Next
If j > 150 Then
Me.DataGridView1.Rows(2).Cells("Amount").Style.BackColor = Color.Red
Timer1.Start()
End If
TextBox1.Text = j.ToString
Then in the timer event something like this:
Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Me.DataGridView1.Rows(2).Cells("Amount").Style.BackColor = Color.Red then
Me.DataGridView1.Rows(2).Cells("Amount").Style.BackColor = Color.Blue
else
Me.DataGridView1.Rows(2).Cells("Amount").Style.BackColor = Color.Red
End If
End Sub
I didn't tested!
Re: [RESOLVED] DataGridView and Timer
i would have done this myself..........:(