如果符合如下规则,是否有隐藏某些按钮?下面是用于创建按钮列的代码和获取匹配项的代码。
我试过 BookButtonCell.Visible = false;,但它说它只是只读的。
谢谢。
private void Form1_Load(object sender, EventArgs e)
{
DataGridViewButtonColumn bookbutton = new DataGridViewButtonColumn();
{
bookbutton.HeaderText = "Book";
bookbutton.Text = "Book";
bookbutton.Name = "Book";
bookbutton.UseColumnTextForButtonValue = true;
}
readalleventsdataGridView.Columns.Add(bookbutton);
int x = 0;
foreach (DataGridViewRow gridRow in readalleventsdataGridView.Rows)
{
DataGridViewCell BookButtonCell = gridRow.Cells["Book"];
DataGridViewCell EndDateCell = gridRow.Cells["EndDate"];
String StrTodayDate = DateTime.Now.ToString("dd/MM/yy");
DateTime TodayDate = Convert.ToDateTime(StrTodayDate);
String StrEndDate = EndDateCell.Value.ToString();
DateTime EndDate = Convert.ToDateTime(StrEndDate);
int result = DateTime.Compare(EndDate, TodayDate);
if (result < 0)
{
What Commands To Hide The Button?
}
x++;
}
}