我想按星期或月份显示约会,但我无法(C#)

即使我选中“月”单选按钮,datagridview也会按周显示约会

Dictionary<int,Hashtable> parsedAppointments = new Dictionary<int,Hashtable>();
// Adjusts appointments that will end up in calendar based on if the Week or Month view is chosen.
foreach (var appointment in appointments)
{
    DateTime startTime = DateTime.Parse(appointment.Value["start"].ToString());
    DateTime endTime = DateTime.Parse(appointment.Value["end"].ToString());
    DateTime today = DateTime.UtcNow;

    if (weekView)
    {
        DateTime sunday = today.AddDays(-(int)today.DayOfWeek);
        DateTime saturday = today.AddDays(-(int)today.DayOfWeek + (int)DayOfWeek.Saturday);

        if (startTime >= sunday && endTime < saturday)
        {
            // only include the apps that get here
            parsedAppointments.Add(appointment.Key,appointment.Value);
        }
    }
    else
    {
        DateTime firstDayOfMonth = new DateTime(today.Year,today.Month,1);
        DateTime lastDayOfMonth = firstDayOfMonth.Addmonths(1).AddDays(-1);
        if (startTime >= firstDayOfMonth && endTime < lastDayOfMonth)
        {
            //  only include apps that get here
            parsedAppointments.Add(appointment.Key,appointment.Value);
        }
    }
}
jjj0716 回答:我想按星期或月份显示约会,但我无法(C#)

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3157151.html

大家都在问