How to change FirstDayOfWeek?

  • Thread starter Thread starter bojan.pikl
  • Start date Start date
B

bojan.pikl

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?
 
Why can't you change it? The FirstDayOfWeek property is writable as far as I
can tell

/claes
 
if(day=="Monday")
System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek=DayOfWeek.Monday;
else
System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek=DayOfWeek.Sunday;

I tried this and it does not work. Should I do something else?
 
using System.Globalization;
....
CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();
CultureInfo uiculture = (CultureInfo)CultureInfo.CurrentUICulture.Clone();
if (day == "Monday")
{
culture.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Monday;
uiculture.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Monday;
}
else
{
culture.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Sunday;
uiculture.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Sunday;
}
System.Threading.Thread.CurrentThread.CurrentCulture = culture;
System.Threading.Thread.CurrentThread.CurrentUICulture = uiculture;

/claes
 
Hi, sorry for late replay, I am really bussy lately.
I tried this, but it does not work eather. Any other suggestion?
 
Please include the context next time so we know what you're responding to

In my last post in this thread I posted the following code:

using System.Globalization;
....
CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();
CultureInfo uiculture = (CultureInfo)CultureInfo.CurrentUICulture.Clone();
if (day == "Monday")
{
culture.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Monday;
uiculture.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Monday;
}
else
{
culture.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Sunday;
uiculture.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Sunday;
}

System.Threading.Thread.CurrentThread.CurrentCulture = culture;
System.Threading.Thread.CurrentThread.CurrentUICulture = uiculture;

Is this not working? How is it not working? What results are you getting?
What results are you expecting?

/claes
 
Back
Top