C
C#2y ago
vamaiotu

❔ trying to make a usercontrol calendar and i need to know how to make a for loop using datetimes

help pls
4 Replies
vamaiotu
vamaiotuOP2y ago
c++
for (DateTime i = new DateTime(Math.Min(prnt.Itms[0].testdate.Ticks, prnt.Itms[0].testdate.Ticks)); new DateTime(Math.Max(prnt.Itms[0].testdate.Ticks, prnt.Itms[0].testdate.Ticks)).CompareTo(i) > 0; i = i.AddDays(1))
{
foreach (CalendarItem itm in prnt.wrp.Children.OfType<CalendarItem>().Where(n => (n.testdate == i)))
{
itm.Color = Brushes.LightBlue;
}


}
c++
for (DateTime i = new DateTime(Math.Min(prnt.Itms[0].testdate.Ticks, prnt.Itms[0].testdate.Ticks)); new DateTime(Math.Max(prnt.Itms[0].testdate.Ticks, prnt.Itms[0].testdate.Ticks)).CompareTo(i) > 0; i = i.AddDays(1))
{
foreach (CalendarItem itm in prnt.wrp.Children.OfType<CalendarItem>().Where(n => (n.testdate == i)))
{
itm.Color = Brushes.LightBlue;
}


}
i got this basically checks which date is bigger then changes the color
vamaiotu
vamaiotuOP2y ago
this is what i'm trying to make but with datetimes cause the way i made that work is with normal for loop and the issue is that when i want to select dates between december 2023 and january 2024 it goes back from january of 2023 because I have no idea how to make it work without having datetimes implemented and because it only uses days of year so how exaclty would i do a for loop using datetimes OK I FIXED IT
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server