Is there anyway to hide certain button if matches a rule as follows? The below is code used to create the button column and the code to get matches.
I tried BookButtonCell.Visible = false;, but it says it is only readonly.
Thanks.
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++;
}
}