Hey
I'm trying to make a Calendar. I want to make my own DayOfWeek enum with danish weekdays and afterwards i want to use it with this call
CultureInfo
.CurrentUICulture.DateTimeFormat.GetDayNamewhich take a System.DayOfWeek argument.
I have maked my own
public enum DayOfWeek
{
Mandag, Tirsdag, Onsdag, Torsdag, Fredag, Lordag, Sondag
}
How can I get this to work together.

Calendar
nhsfreak
for
(int i = 0; i < 7; i++){
ColumnDayCell c = new ColumnDayCell();c.DisplayIndex = i;
c.HeaderCell.Style.Alignment =
DataGridViewContentAlignment.MiddleCenter; c.HeaderCell.Value = CultureInfo.CurrentUICulture.DateTimeFormat.GetDayName((DayOfWeek)((i + 1) % 7)); this.Columns.Add(c);}
but with danish weekdays.
I get errors saying that Error
The best overloaded method match for 'WinKalender.Calender.GetDayOfWeekNumber(WinKalender.Calender.DayOfWeek)' has some invalid arguments C:\WinKalender\WinKalender\Calender.cs 135 55 WinKalender
Solitaire
Hi.
To be honest, I don't understand why you want this... but maybe this helps you.
public enum DayOfWeek
{
Mandag = System.DayOfWeek.Monday,
Tirsdag = System.DayOfWeek.Tuesday,
Onsdag = System.DayOfWeek.Wednesday,
Torsdag = System.DayOfWeek.Thursday,
Fredag = System.DayOfWeek.Friday,
Lordag = System.DayOfWeek.Saturday,
Sondag = System.DayOfWeek.Sunday
}
Then, you would simply call the GetDayName method like this:
DayOfWeek day = DayOfWeek.Mandag;
string strDay = CultureInfo.CurrentUICulture.DateTimeFormat.GetDayName((System.DayOfWeek)day);
Is this what you wanted
Just to satisfy my curiosity... why do you want to use your own enumeration
Regards,
Fernando.
rofu
I'm sorry, but I still fail to understand your problem.
I'm from Uruguay, and if I was to make a calendar, CultureInfo.CurrentUICulture.DateTimeFormat.GetDayName(DayOfWeek.Friday) would return "Viernes"... and that's pretty much what I would want.
Can you help me understand what the problem is
Pavan Contractor
IS dude
This error occurs when you are trying to buill the application, right
It appears the something goes running in the calling of the method GetDayOfWeekNumber. My guess is that since your Enumeration has the same name than Sysytem.DayOfWeek, you are using the wrong enumeration as parameter. Try using the Namespace (in the declaration and where you call it) or change your enumeration's name to avoid ambiguity.
Another thing, wherever you call this method is not in the code you posted, so if you can't solve the problem, please post the method's signature and where you call it.
ErrolDC
I've solved the problem. I made an object of the cultureinfo class
CultureInfo dkl = new CultureInfo( "dk-DK" );
Then the danish weekdays work without making a new enum of weekdays
Thanks Anyway