By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,238 Members | 1,901 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,238 IT Pros & Developers. It's quick & easy.

In a combobox, how do I change the data type to an Integer?

P: 3
I want to have a simple comboBox1 that displays a DropDownList consisting of the number 1 thru 12.

How do I get the comboBox1 data type to be an Int instead of a String??

Thanks in advance for help in this matter.
Mar 2 '10 #1

✓ answered by tlhintoq

You don't. Combobox items are strings.
But you can easily convert a string to an int.

Convert.ToInt(myCombobox.SelectedItem);

Share this Question
Share on Google+
4 Replies


P: 26
you mean you want to get the value of the selected item?

Convert.ToInt32(comboBox1.SelectedItem.ToString()) ;
Mar 2 '10 #2

P: 3
I guess what I mean is that I want to use the 'selected item' as an integer. For some reason I cannot get it changed from a String. There has to be something elementary that I'm looking over.
Thanks.........................
Mar 2 '10 #3

tlhintoq
Expert 2.5K+
P: 3,525
You don't. Combobox items are strings.
But you can easily convert a string to an int.

Convert.ToInt(myCombobox.SelectedItem);
Mar 2 '10 #4

P: 3
Thanks!!

I was looking at it the wrong way.
Mar 2 '10 #5

Post your reply

Sign in to post your reply or Sign up for a free account.