B
Bajtitou
Guest
Hi,
I am using this Code to changing the color of a row in Datagridview if date and time match Now.
Private Sub Dgw_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs) Handles Dgw.CellFormatting
If Not Dgw.Rows(e.RowIndex).IsNewRow Then
If e.ColumnIndex = Dgw.Columns("DateDeCouvaison").Index Then
e.CellStyle.Format = "d"
Dim TheDate As Date = CDate(e.Value)
Console.WriteLine(TheDate.ToShortDateString)
If TheDate.ToShortDateString = Now.AddDays(-2).ToShortDateString Then
e.CellStyle.BackColor = Color.SpringGreen
e.CellStyle.ForeColor = Color.Red
End If
If TheDate.ToShortDateString = Now.AddDays(-2).ToShortDateString Then
e.CellStyle.Font =
New System.Drawing.Font(
"Segoe UI Semibold",
9.0!,
System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point,
CType(0, Byte)
)
End If
End If
End If
End Sub
The code is running very Well whithout the last line which is a Total line,
Is there a way to avoid that this line To be not supported during Cellformating event.
Thank you Very Much and Best Regards.
Continue reading...
I am using this Code to changing the color of a row in Datagridview if date and time match Now.
Private Sub Dgw_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs) Handles Dgw.CellFormatting
If Not Dgw.Rows(e.RowIndex).IsNewRow Then
If e.ColumnIndex = Dgw.Columns("DateDeCouvaison").Index Then
e.CellStyle.Format = "d"
Dim TheDate As Date = CDate(e.Value)
Console.WriteLine(TheDate.ToShortDateString)
If TheDate.ToShortDateString = Now.AddDays(-2).ToShortDateString Then
e.CellStyle.BackColor = Color.SpringGreen
e.CellStyle.ForeColor = Color.Red
End If
If TheDate.ToShortDateString = Now.AddDays(-2).ToShortDateString Then
e.CellStyle.Font =
New System.Drawing.Font(
"Segoe UI Semibold",
9.0!,
System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point,
CType(0, Byte)
)
End If
End If
End If
End Sub
The code is running very Well whithout the last line which is a Total line,
Is there a way to avoid that this line To be not supported during Cellformating event.
Thank you Very Much and Best Regards.
Continue reading...