bạn tham khảo nhé:
đầu tiên lấy dữ liệu từ database cho vào 1 datatable, rồi dùng dataGridViewX1 để hiển thị cái datatable đó
Code:
for (i = 0; i < dataGridViewX1.Rows.Count; i++)
{
if (dataGridViewX1.Rows[i].Cells[x].Value.ToString() == "True")//nếu giá trị là True thì chuyển thành màu đỏ
{
dataGridViewX1.Rows[i].Cells[x].Style.ForeColor = Color.Red;
}
else//nếu không phải True thì chuyển thành màu xanh
{
dataGridViewX1.Rows[i].Cells[x].Style.ForeColor = Color.Blue;
}
}
với x là thứ tự của cột Trạng thái trên dataGridViewX1