Good day,
Base to the image I try in input date from June 8 until July 1, but no display colors in my datagridview., I don’t know why.
and here my code
<code>int offset = 4;
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (!row.IsNewRow)
{
if (row.Cells.Count >= 4)
{
DateTime startBook;
DateTime endBook;
if (DateTime.TryParse(row.Cells[2].Value?.ToString(), out startBook) &&
DateTime.TryParse(row.Cells[3].Value?.ToString(), out endBook))
{
int startBook_C = startBook.Day;
int endBook_C = endBook.Day;
int TotalDays = endBook_C - startBook_C;
for (int a = 0; a <= TotalDays; a++)
{
dataGridView1.Rows[row.Index].Cells[offset + startBook_C - 1 + a].Style.BackColor = Color.Blue;
}
}
}
}
}
</code>
<code>int offset = 4;
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (!row.IsNewRow)
{
if (row.Cells.Count >= 4)
{
DateTime startBook;
DateTime endBook;
if (DateTime.TryParse(row.Cells[2].Value?.ToString(), out startBook) &&
DateTime.TryParse(row.Cells[3].Value?.ToString(), out endBook))
{
int startBook_C = startBook.Day;
int endBook_C = endBook.Day;
int TotalDays = endBook_C - startBook_C;
for (int a = 0; a <= TotalDays; a++)
{
dataGridView1.Rows[row.Index].Cells[offset + startBook_C - 1 + a].Style.BackColor = Color.Blue;
}
}
}
}
}
</code>
int offset = 4;
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (!row.IsNewRow)
{
if (row.Cells.Count >= 4)
{
DateTime startBook;
DateTime endBook;
if (DateTime.TryParse(row.Cells[2].Value?.ToString(), out startBook) &&
DateTime.TryParse(row.Cells[3].Value?.ToString(), out endBook))
{
int startBook_C = startBook.Day;
int endBook_C = endBook.Day;
int TotalDays = endBook_C - startBook_C;
for (int a = 0; a <= TotalDays; a++)
{
dataGridView1.Rows[row.Index].Cells[offset + startBook_C - 1 + a].Style.BackColor = Color.Blue;
}
}
}
}
}