I have a datagridview with a date column. I'm making a printable report of that datagridview. For that I'm using this line of code:
e.Graphics.DrawString(dataGridView1.Rows[i].Cells["Date"].FormattedValue.ToString(), new Font("Arial", 10, FontStyle.Regular), Brushes.Black, x, 140 + height);
This gives me an output on the report in this format 11/09/2021 10:15 I'd like to have the date on the report, without the time: 11/09/2021
So far I've tried this:
e.Graphics.DrawString(dataGridView1.Rows[i].Cells["Date"].FormattedValue.ToString("dd/MM/yyyy"), new Font("Arial", 10, FontStyle.Regular), Brushes.Black, x, 140 + height);
: this gives me the following error: 'No overload for method 'ToString' takes 1 argument'string date = dataGridView1.Rows[i].Cells["Date"].FormattedValue.ToString(); newdate = date.Substring(0, 9);
this gives me the following error when rendering the report: 'System.ArgumentOutOfRangeException: 'index and length must refer to a location within the string. parameter name'
At the moment, I'm out of inspiration..... Any suggestions?
Kind regards, Christophe