Results 1 to 3 of 3

Thread: [RESOLVED] DataGridView and Timer

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2009
    Posts
    1,103

    Resolved [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

  2. #2
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    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!
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2009
    Posts
    1,103

    Re: [RESOLVED] DataGridView and Timer

    i would have done this myself..........

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