title: How to set focus on ComboBox in Windows Forms App (Visual Studio,VB.Net)?
body: <p><strong>Update:</strong> I was able to get the ComboBox to focus but I had to go into Project>Properties and switch the application type to "ConsoleApp" and then I was able to get the combobox to focus in blue. I would still love to know how to do this natively in Windows Forms app though, as .Focus() doesn't seem to work and everything else I tried:
  <a href="https://i.stack.imgur.com/GGJrs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GGJrs.png" alt="enter image description here"></a></p>
  
  <p><strong>Original Question:</strong> this is maybe a trivial question but I've searched on google and tried different methods but could not get my simple GUI Windows Form App (.NET) to set <strong>focus</strong> on one of my ComboBoxes after erroring (i.e. when ComboBox value is not selected, program should throw MessageBox error then set <strong>focus</strong> to that specific ComboBox). I've been trying .select() and focus() and changing the tab-index.</p>
  
  <p>My two ComboBoxes are to the right of the From: and To: TextBoxes and have the names <strong>cboFrom</strong> and <strong>cboTo</strong>. The ComboBox style is <strong>DropDownList</strong></p>
  
  <p>Option Explicit: <strong>ON</strong></p>
  
  <p>Option Strict: <strong>ON</strong></p>
  
  <p>Option Infer: <strong>Off</strong></p>
  
  <p>And <strong>unselected</strong> Microsoft.VisualBasic for under "References" in project properties.</p>
  
  <p>This is the GUI:
  <a href="https://i.stack.imgur.com/yBYFr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yBYFr.png" alt="enter image description here"></a></p>
  
  <p>And how it looks when it throws error for a ComboBox is empty and Convert is clicked:
  <a href="https://i.stack.imgur.com/qTNO0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qTNO0.png" alt="enter image description here"></a></p>
  
  <p>And this is the code that throws an Error message if any or both of the ComboBoxes are empty. It should <strong>focus</strong> back to the ComboBox that was empty, but it's not.</p>
  
  <pre><code>Private Sub btnConvert_Click(sender As Object, e As EventArgs) Handles btnConvert.Click
  
      Dim dValueOfTxtBoxFrom As Double = 0
  
      If Me.cboFrom.SelectedIndex = -1 AndAlso Me.cboTo.SelectedIndex = -1 Then
        MessageBox.Show("Please select temperature units to convert from and to.", "Error: 10001", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        'btnReset.Select() 'works fine
  
      ElseIf cboFrom.SelectedIndex = -1 OrElse cboTo.SelectedIndex = -1 Then
        MessageBox.Show("Please select temperature units to convert from and to.", "Error: 10001", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        'btnExit.Select() 'works fine
  
      End If
  </code></pre>