All replies

  • combobox.selectedIndex.toString();

    Every day its a new learning. Keep Learning!!
    If this post answers your question, please click Mark As Answer . If this post is helpful please click Mark as Helpful
    Monday, January 09, 2012 12:21 PM
  • Hi
    Combobox Index Always starts with 0
    So if you select 3rd item the index is 2
    Code Snipt:

               String s;
                if( comboBox1.SelectedIndex>=0)
                s = comboBox1.SelectedIndex.ToString();

    A Pathfinder.


    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful"
    Monday, January 09, 2012 12:27 PM
  • It does not work .

    error: Cannot implicitly convert type 'string' to 'int'

    Monday, January 09, 2012 12:28 PM

    String teacherField = comboBox_tchrLevel.SelectedIndex.ToString();

    I try this but it does not work 

    Error:Cannot implicitly convert type 'string' to 'int'

    Monday, January 09, 2012 12:40 PM
  • > String teacherField = comboBox_tchrLevel.SelectedIndex.ToString();

    There is nothing in this statement that should require conversion from a string to an Integer, as the error message states. 

    Are you sure this is your actual code?

    On the off-chance that it is, put a breakpoint on the errant line, then run these in the Immediate Window - what do they return?

    ? combobox_tchrLevel.GetType().ToString()
    ? combobox_tchrLevel.SelectedIndex.GetType().ToString()
    ? combobox_tchrLevel.SelectedIndex.ToString().GetType().ToString()
    ? teacherField.GetType().ToString()

    Regards, Phill W.
    Monday, January 09, 2012 2:27 PM
  • Hi Junaid,
    According to your description, I think you used teacherField as an Int(see, could you post the code which throws the error message? If you can’t find the code, please post the entire code.
    Best Regards,

    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us
    Tuesday, January 10, 2012 7:11 AM