Solved

Enumeration for months?

Posted on 2006-07-20
4
234 Views
Last Modified: 2010-04-16
Hi all, I'm trying to convert a string value selected from a drop down control to a numeric value and having trouble.  List of values are the months, spelled out (January, February,...).  When the user selects one of these, I want to be able to convert this TimeFrame.SelectedValue to an int, January = 1, Feb =2....   integer variable is monthstart.

I don't have much (ok, any) experience with enumerations, but from what I do understand about the language, this is probably way to go.  How can I make the conversion??

Any help would be appreciated,

Thanks in advanced

0
Comment
Question by:aaalife
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
osmantemiz earned 500 total points
ID: 17148033
first of all you dont have to use enumaration for that kind of thing just do that

TimeFrame.Items.Clear();
TimeFrame.Items.Add("Select Month");
TimeFrame.Items.Add("January");
TimeFrame.Items.Add("February);
.
.
.
.
.// just add like this
.
.
TimeFrame.Items.Add("December");

Now if you get the TimeFrame.SelectedValue it will return your int :)
0
 
LVL 3

Expert Comment

by:osmantemiz
ID: 17148038
sorry... Not SelectedValue you should get SelectedIndex ...
0
 

Author Comment

by:aaalife
ID: 17148116
i need January to =1, will TimeFrame.SelectedIndex start at 0, so i have to + 1, or does the index start with 1??
0
 

Author Comment

by:aaalife
ID: 17148122
never mind, re-read your answer, got it.

thanks
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.NET - Refactor Class per SOLID principles 2 43
C# XML Get Values 4 54
asp.net, radiobuttonlist, c# 3 70
Easiest intro into .NET CORE? 2 34
Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question