我正在使用c#创建日记应用程序。我有一个datagridview,我想从本周开始的每年的每个星期一显示一年。下面是我到目前为止的代码:
//Loop which goes through every Monday 50 times,therefore it displays every Monday for a year on the users profile.
int x = 0;
do
{
x = x + 1;
string monday = DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek + (int)DayOfWeek.Monday).ToString("dd-MM-yyyy");
metroDataGrid1.Rows.Add(monday);
}
while (x < 50);
//After 50 weeks have been displayed it will reset the count to 0.
if(x == 50)
{
x = 0;
}
foreach (DataGridViewRow row in metroDataGrid1.Rows)
{
row.Height = 60;
}
我才刚刚开始学习c#,因此为什么这可能是遥不可及的...
当前,它在DGV中显示当前星期一(每周50次)。见下文:
我需要它以dd / MM / yyyy格式显示下一年的每个星期一。例如 18/11/2019 25/11/2019 2019/02/12 2019/09/12 16/12/2019 ...
感谢您的帮助。