Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this code that works perfect, compares datagridview cell date values (connected to an sql server table) and changes the cell, that meets the compare statement, background to beige collor, I want to copy these cells and their value with their caption and a cell of their row called car_num, to a new datagrid so the user informed that the date of the "service" of the car is in the desired date.

VB
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim dt As New Date
        For Each row As DataGridViewRow In DataGridView1.Rows

            For c As Int32 = 0 To DataGridView1.ColumnCount - 1
                If row.Cells(c).Value IsNot DBNull.Value Then
                   dt = Date.Parse(row.Cells(c).Value)
                   If (Date.Today >= (dt.AddMonths(-1))) And (Date.Today <= dt) Then
                    row.Cells(c).Style.BackColor = Color.Beige
                    MessageBox.Show("date,car num, name", "date")
                     End If
                End If
            Next
        Next
    End Sub
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900