title: Binding enum in combobox
body: <p><code>enter code here</code>Given this exmample:</p>
  
  <pre><code>  Public Enum Gender
     Masculine
     Femenine
    End Enum
  
  public class ViewModel
  
  private _gender as Gender
  
      Public Property Gender() As Gender
        Get
          Return _gender 
        End Get
        Set(ByVal value As Gender)
          _gender = value
        End Set
      End Property
  
  end class
  
   Private Sub Form_Load
  
  
   cmbGender.DataSource = [Enum].GetValues(GetType(Enums.Sexo)) //combobox shows gender ok
   cmbGender.DataBindings.Add(New Binding("SelectedItem",ViewModel , "Gender", False, DataSourceUpdateMode.OnPropertyChanged))
  
  end sub
  </code></pre>
  
  <p><code>Combobox</code> use <code>ViewModel</code> getter to set its <code>SelectedItem</code> as soon as the <code>Databindings.Add</code> executes but never use the setter when <code>SelectedItem</code> change in the User Interface.</p>
  
  <p>What I am doing wrong?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Thanks to Sriram Sakthivel to enlighten me and check combobox events. The final situation is:</p>
  
  <p>Using <code>SelectedItem</code>, <code>DataSourceUpdateMode.OnValidation</code> and <code>combobox.causesValidation = true</code> works when <code>LostFocus</code> raises. If you need <code>onPropertyChanged</code> you should use <code>SelectedIndex</code> and the Sriram Sakthivel's code below.</p>