VB.NETで、下図の様なDataGridViewを作成し、Value列を変更した際に、MinもしくはMaxの値の範囲に入ってなかったらValueのセルの色を変えるイベントを作成したいと思っています。
vb.net
1Private Sub DataGridView1_CellFormatting(ByVal sender As Object, _ 2 ByVal e As DataGridViewCellFormattingEventArgs) _ 3 Handles DataGridView1.CellFormatting 4 Dim dgv As DataGridView = CType(sender, DataGridView) 5 6 'セルの列を確認 7 If dgv.Columns(e.ColumnIndex).Name = "Column1" AndAlso TypeOf e.Value Is Integer Then 8 Dim val As Integer = CInt(e.Value) 9 10 'セルの値により、背景色を変更する 11 If val > 0 Then 12 e.CellStyle.BackColor = Color.Yellow 13 ElseIf val = 0 Then 14 e.CellStyle.BackColor = Color.Red 15 End If 16 17 End If 18 End Sub
他サイトを参考に上記の様なコードを記述し、0より大きい数字の時に黄色になることは確認したのですが、条件式にMinやMaxの値をどのように記述すれば良いかが分かりません。
ご教授お願い致します。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/01/05 04:03