将突出显示的单元格复制到新的datagrid [英] copy highlighted cells to new datagrid
本文介绍了将突出显示的单元格复制到新的datagrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个完美的代码,比较datagridview单元格日期值(连接到sql server表)并更改单元格,符合比较语句,背景为米色collor,我想复制这些单元格及其值他们的标题和他们的行的单元格car_num,到一个新的数据网格,以便用户通知汽车的服务日期在所需的日期。
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.
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
推荐答案
这篇关于将突出显示的单元格复制到新的datagrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文