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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KitCarson
    New Member
    • Mar 2010
    • 3

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

    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.
  • kurtzky
    New Member
    • Nov 2008
    • 26

    #2
    you mean you want to get the value of the selected item?

    Convert.ToInt32 (comboBox1.Sele ctedItem.ToStri ng());

    Comment

    • KitCarson
      New Member
      • Mar 2010
      • 3

      #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......... ............... .

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

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

        Convert.ToInt(m yCombobox.Selec tedItem);

        Comment

        • KitCarson
          New Member
          • Mar 2010
          • 3

          #5
          Thanks!!

          I was looking at it the wrong way.

          Comment

          Working...