title: Get the selected value from a combobox C#
body: <p>I have read through a bunch of topic on this subject. I've tried a lot of variations, but for some reason, I can't get this to work. Here's the problem: I have a combobox that is populated with the sheet names from an Excel workbook. (I'll include that code, in case the problem is there) When I try to get the selected text value, I get nothing. What am I doing wrong?</p>
  
  <pre><code>    /********************************************************************************
       * The following code takes in an excel filename and populates a combobox based 
       * on the excel tab names.
       ********************************************************************************/
      private void GetExcelSheetNames(string excelFile)
      {
          _Application xlApp;
          Workbook xlTemplateWB;
  
          xlApp = new ApplicationClass();
  
          xlTemplateWB = xlApp.Workbooks.Open(Elmnt.getDBPath() + TEMPLATENAME, 0, true,
              5, "", "", false, XlPlatform.xlWindows, "", true, false, 0, true, false, false);
  
          foreach (Worksheet temp in xlTemplateWB.Worksheets)
          {
              cboBenchSheets.Items.Add(temp.Name);
          }
  
          xlTemplateWB.Close(true, Missing.Value, Missing.Value);
          xlApp.Quit();
      }
  
      /********************************************************************************
       * This returns the selected item in the cboBenchSheets combo box
       ********************************************************************************/
      public String getSelection()
      {
          String selected;
          selected = cboBenchSheets.Text;                                         //Returns nothing
          selected = cboBenchSheets.SelectedText;                                 //Returns nothing
          selected = cboBenchSheets.SelectedValue.ToString();                     //Returns nothing
          selected = cboBenchSheets.GetItemText(cboBenchSheets.SelectedIndex);    //Returns -1
  
          return selected;
      }
  </code></pre>