如何通过将其与DatePaid列中的任何内容进行比较,如何隐藏dataGridView上与“27/10/2013”日期不匹配的所有行。我检查了我的mdb数据库(我从中提取数据),DataPaid的数据类型为ShortText,因此不需要转换为DateTime。目前,下面的代码隐藏了我的所有行。
public void viewOverdue_Click(object sender, EventArgs e)
{
viewOverdue.ForeColor = Color.Red;
viewHistory.ForeColor = Color.Black;
viewHire.ForeColor = Color.Black;
viewRent.ForeColor = Color.Black;
CurrencyManager manager = (CurrencyManager)BindingContext[dataGridView1.DataSource];
manager.SuspendBinding();
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (!string.Equals(row.Cells[0].Value.ToString(), "27/10/2013", StringComparison.OrdinalIgnoreCase))
{
row.Visible = false;
}
else
{
row.Visible = true;
}
}
manager.ResumeBinding();
}