Click here to Skip to main content
15,891,033 members
Home / Discussions / C#
   

C#

 
GeneralRe: illegal characters in path - system.argumentException Pin
V.5-Apr-12 1:32
professionalV.5-Apr-12 1:32 
GeneralRe: illegal characters in path - system.argumentException Pin
ausia195-Apr-12 5:42
ausia195-Apr-12 5:42 
GeneralRe: illegal characters in path - system.argumentException Pin
Pete O'Hanlon5-Apr-12 5:48
mvePete O'Hanlon5-Apr-12 5:48 
GeneralRe: illegal characters in path - system.argumentException Pin
ausia195-Apr-12 6:03
ausia195-Apr-12 6:03 
GeneralRe: illegal characters in path - system.argumentException Pin
ausia195-Apr-12 6:03
ausia195-Apr-12 6:03 
GeneralRe: illegal characters in path - system.argumentException Pin
V.5-Apr-12 6:21
professionalV.5-Apr-12 6:21 
AnswerRe: illegal characters in path - system.argumentException Pin
Eddy Vluggen5-Apr-12 1:15
professionalEddy Vluggen5-Apr-12 1:15 
QuestionPopulate ComboBox with DayOfWeek enum? Pin
kbalias5-Apr-12 0:06
kbalias5-Apr-12 0:06 
Good day

I am using Visual Studio 2010 to develop a Windows app. I am busy with a module where the user can specify setting for days of the week, for example Mondays the lunch duration is 1 hour, Tuesday it is 30 minutes, and so on.

I want to display the days of the week (Sunday, Monday, …) in a ComboBox so that the user can select a day.
The DisplayMember must be the name, e.g Monday
The ValueMember must be the ordinal number of the day in the DayOfWeek enum, e.g. 1

How do I populate the ComboBox using the DayOfWeek enumerator?

I tried:

private void Form1_Load(object sender, EventArgs e)
{
    for (int j = 0; j < 7; j++)
    {
        comboDay.Items.Add((DayOfWeek)j);
    }
}



private void comboDay_SelectedIndexChanged(object sender, EventArgs e)
{
    MessageBox.Show("Selected Day = " + comboDay.SelectedValue);
}


This shows the DayOfWeek names in the combobox, but the SelectedValue is always null.

Any suggestions on better ways of doing this?

Thanks.
Kobus
AnswerRe: Populate ComboBox with DayOfWeek enum? Pin
Pete O'Hanlon5-Apr-12 0:16
mvePete O'Hanlon5-Apr-12 0:16 
GeneralRe: Populate ComboBox with DayOfWeek enum? Pin
kbalias5-Apr-12 0:26
kbalias5-Apr-12 0:26 
GeneralRe: Populate ComboBox with DayOfWeek enum? Pin
Pete O'Hanlon5-Apr-12 0:27
mvePete O'Hanlon5-Apr-12 0:27 
QuestionPLSSS TELL ME DECLERING LIST IN C# AS FOOLOWS IS WRONG OR RIGHT? Pin
ashok01434-Apr-12 23:10
ashok01434-Apr-12 23:10 
AnswerRe: PLSSS TELL ME DECLERING LIST IN C# AS FOOLOWS IS WRONG OR RIGHT? Pin
Pete O'Hanlon4-Apr-12 23:27
mvePete O'Hanlon4-Apr-12 23:27 
AnswerRe: PLSSS TELL ME DECLERING LIST IN C# AS FOOLOWS IS WRONG OR RIGHT? Pin
OriginalGriff4-Apr-12 23:28
mveOriginalGriff4-Apr-12 23:28 
GeneralRe: PLSSS TELL ME DECLERING LIST IN C# AS FOOLOWS IS WRONG OR RIGHT? Pin
Shameel5-Apr-12 4:58
professionalShameel5-Apr-12 4:58 
GeneralRe: PLSSS TELL ME DECLERING LIST IN C# AS FOOLOWS IS WRONG OR RIGHT? Pin
OriginalGriff5-Apr-12 5:55
mveOriginalGriff5-Apr-12 5:55 
QuestionVKontakte API request Pin
tfile1014-Apr-12 22:07
tfile1014-Apr-12 22:07 
AnswerRe: VKontakte API request Pin
Pete O'Hanlon4-Apr-12 22:11
mvePete O'Hanlon4-Apr-12 22:11 
AnswerRe: VKontakte API request Pin
Eddy Vluggen5-Apr-12 1:27
professionalEddy Vluggen5-Apr-12 1:27 
Questionsystem.reflection.targetinvocationexception when pas null referecne to COM Pin
yanghua944-Apr-12 20:41
yanghua944-Apr-12 20:41 
AnswerRe: system.reflection.targetinvocationexception when pas null referecne to COM Pin
Abhinav S4-Apr-12 21:59
Abhinav S4-Apr-12 21:59 
GeneralRe: system.reflection.targetinvocationexception when pas null referecne to COM Pin
yanghua944-Apr-12 22:57
yanghua944-Apr-12 22:57 
Questionhelp needed for Virtual memory Pin
tatsat4-Apr-12 19:27
tatsat4-Apr-12 19:27 
QuestionHow to edit textbox that is bound with int Pin
kruegs354-Apr-12 10:50
kruegs354-Apr-12 10:50 
AnswerRe: How to edit textbox that is bound with int Pin
JOAT-MON4-Apr-12 14:22
JOAT-MON4-Apr-12 14:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.