Hi, I am making a calendar. It is costum made and I would like to have
the ability to choose the first day (Monday or Sunday). I know for the
firstDayOfWeek, but I can't change it. What should I do?
I tried this but it does not work (it is always Sunday):
using System.Globaliz ation;
....
CultureInfo culture = (CultureInfo)Cu ltureInfo.Curre ntCulture.Clone ();
CultureInfo uiculture =
(CultureInfo)Cu ltureInfo.Curre ntUICulture.Clo ne();
if (day == "Monday")
{
culture.DateTim eFormat.FirstDa yOfWeek = DayOfWeek.Monda y;
uiculture.DateT imeFormat.First DayOfWeek = DayOfWeek.Monda y;
}
else
{
culture.DateTim eFormat.FirstDa yOfWeek = DayOfWeek.Sunda y;
uiculture.DateT imeFormat.First DayOfWeek = DayOfWeek.Sunda y;
}
System.Threadin g.Thread.Curren tThread.Current Culture = culture;
System.Threadin g.Thread.Curren tThread.Current UICulture = uiculture;
The code works fine but it's always Sunday the first day of week. I
would like to change this.
And here is my code:
int DayIndex;
DateTime objDate=new DateTime(Year,M onth,Day);
//First day of week.
int StartDayIndex=( int)objDate.Day OfWeek;
//Empty array days.
for(int i=0; i<37; i++)
days[i]=0;
for(int i=0; i<31; i++)
{
DayIndex=(Start DayIndex+i);
if(i < DateTime.DaysIn Month(Year,Mont h))
{
days[DayIndex]=(i+1);
}
else
{
days[DayIndex]=0;
}
}
the ability to choose the first day (Monday or Sunday). I know for the
firstDayOfWeek, but I can't change it. What should I do?
I tried this but it does not work (it is always Sunday):
using System.Globaliz ation;
....
CultureInfo culture = (CultureInfo)Cu ltureInfo.Curre ntCulture.Clone ();
CultureInfo uiculture =
(CultureInfo)Cu ltureInfo.Curre ntUICulture.Clo ne();
if (day == "Monday")
{
culture.DateTim eFormat.FirstDa yOfWeek = DayOfWeek.Monda y;
uiculture.DateT imeFormat.First DayOfWeek = DayOfWeek.Monda y;
}
else
{
culture.DateTim eFormat.FirstDa yOfWeek = DayOfWeek.Sunda y;
uiculture.DateT imeFormat.First DayOfWeek = DayOfWeek.Sunda y;
}
System.Threadin g.Thread.Curren tThread.Current Culture = culture;
System.Threadin g.Thread.Curren tThread.Current UICulture = uiculture;
The code works fine but it's always Sunday the first day of week. I
would like to change this.
And here is my code:
int DayIndex;
DateTime objDate=new DateTime(Year,M onth,Day);
//First day of week.
int StartDayIndex=( int)objDate.Day OfWeek;
//Empty array days.
for(int i=0; i<37; i++)
days[i]=0;
for(int i=0; i<31; i++)
{
DayIndex=(Start DayIndex+i);
if(i < DateTime.DaysIn Month(Year,Mont h))
{
days[DayIndex]=(i+1);
}
else
{
days[DayIndex]=0;
}
}
Comment