Windowsフォーム.net 3.5でExcelとSqlサーバーの間でデータを転送する一括挿入アプリを構築しています 問題は、ExcelデータがSqlサーバーに移動する前にいくつかの変更を必要とする場合があることです。プロセス中の層。
アプリケーションは、1 つの datagridview で Excel コンテンツを取得し、背景色の変更、ツールチップなどを使用していくつかの検証を行います。したがって、検証のあるセルがいくつかある場合、ユーザーは F2 を押してそれぞれのコンテンツを変更します。
問題は、ユーザーがセルの変更を終了したときに、検証手順 (背景色の行の変更、ツールチップの追加など) を再度適用したいのですが、これはもう機能せず、一度だけ機能することです。つまり、datagridview セルにいくつかの変更を加えた後、セルの背景色を変更する方法は機能しません。
いくつかのアイデア?みんな、ありがとう。
ノート:
これは、私の 4 つの検証方法の 1 つです。
**enter code here**
Public Sub Validate()
For Each x As DataGridViewRow In DataGridView1.Rows
If IsDBNull(x.Cells(0).Value) Then
DataGridView1.Rows(x.Index).Cells(0).Style.BackColor = Color.Red
End If
If IsDBNull(x.Cells(1).Value) Then
DataGridView1.Rows(x.Index).Cells(1).Style.BackColor = Color.Red
End If
If IsDBNull(x.Cells(2).Value) Then
DataGridView1.Rows(x.Index).Cells(2).Style.BackColor = Color.Red
End If
If IsDBNull(x.Cells(3).Value) Then
DataGridView1.Rows(x.Index).Cells(3).Style.BackColor = Color.Yellow
End If
If IsDBNull(x.Cells(4).Value) Then
DataGridView1.Rows(x.Index).Cells(4).Style.BackColor = Color.Yellow
End If
If IsDBNull(x.Cells(5).Value) Then
DataGridView1.Rows(x.Index).Cells(5).Style.BackColor = Color.Yellow
End If
If IsDBNull(x.Cells(6).Value) Then
DataGridView1.Rows(x.Index).Cells(6).Style.BackColor = Color.Red
End If
If IsDBNull(x.Cells(7).Value) Then
DataGridView1.Rows(x.Index).Cells(7).Style.BackColor = Color.Red
End If
If IsDBNull(x.Cells(8).Value) Then
DataGridView1.Rows(x.Index).Cells(8).Style.BackColor = Color.Yellow
End If
If IsDBNull(x.Cells(9).Value) Then
DataGridView1.Rows(x.Index).Cells(9).Style.BackColor = Color.Yellow
End If
If IsDBNull(x.Cells(10).Value) Then
DataGridView1.Rows(x.Index).Cells(10).Style.BackColor = Color.Yellow
End If
If IsDBNull(x.Cells(11).Value) Then
DataGridView1.Rows(x.Index).Cells(11).Style.BackColor = Color.Yellow
End If
If IsDBNull(x.Cells(12).Value) Then
DataGridView1.Rows(x.Index).Cells(12).Style.BackColor = Color.Yellow
End If
If IsDBNull(x.Cells(13).Value) Then
DataGridView1.Rows(x.Index).Cells(13).Style.BackColor = Color.Red
End If
If IsDBNull(x.Cells(14).Value) Then
DataGridView1.Rows(x.Index).Cells(14).Style.BackColor = Color.Red
End If
If IsDBNull(x.Cells(15).Value) Then
DataGridView1.Rows(x.Index).Cells(15).Style.BackColor = Color.Red
End If
If IsDBNull(x.Cells(16).Value) Then
DataGridView1.Rows(x.Index).Cells(16).Style.BackColor = Color.Yellow
End If
If IsDBNull(x.Cells(17).Value) Then
DataGridView1.Rows(x.Index).Cells(17).Style.BackColor = Color.Yellow
End If
If IsDBNull(x.Cells(18).Value) Then
DataGridView1.Rows(x.Index).Cells(18).Style.BackColor = Color.Red
End If
If IsDBNull(x.Cells(19).Value) Then
DataGridView1.Rows(x.Index).Cells(19).Style.BackColor = Color.Red
End If
If IsDBNull(x.Cells(20).Value) Then
DataGridView1.Rows(x.Index).Cells(20).Style.BackColor = Color.Red
End If
Next
End Sub