On the form there is a DataGridView, which is filled from Access. This table has several columns and unlimited number of lines. From this table, I need to somehow take all the dates from the “Data” column and compare them with the real date if this date is more withdrawing a message. How can this be done?
Answer 1
Private Void Button1_Click (Object Sender, Eventargs E)
{
Foreach (DataGridView Row in DataGridView1.rows) // Watch all the lines in the table
{
Foreach (DataGridViewCell Cell In Row.cells) // Watch out all cells in each row
{
if (cel.columnindex == 2) // Check which column belongs to the cell (specify the index of your column)
{
Datetime datagridvalue = convert.todatetime (cel.value); // Transform the cell value to DATETIME Data Type
if; datagridvalue & lt; datetime.Now) // compare the value from the cell and the current date
{
MessageBox.Show ("Current Date View");
}
ELSE.
{
MessageBox.Show ("current date less");
}
}
}
}
}