title: C# Combo box events
body: <p>Currently I'm in the middle of making a small app in c# that requires the user to make a selection of an object using a combo box, from there the user can edit properties of that object below and then save them to a database.</p>
  
  <p>I'm having an issue though when trying to ask the user whether they would like to cancel when they click on the combo box again but have changes to save.</p>
  
  <p>the best I have is below, but users can still use a keyboard to select items even when the drop down height means they can't see the options.</p>
  
  <pre><code>private void cmbBooks_DropDown( object sender, EventArgs e )
          {
          if ( CheckSave( ) )     //checksave returns true if they want to cancel
              {
              cmbBooks.DropDownHeight = 1;
              }
          }
  </code></pre>
  
  <p>thanks</p>
  
  <p><em>EDIT</em>
  I've tried it with the SelectedIndexChanged event and from there I can stop the box carrying on and opening that object but then the combo box would stay selecting the object they tried to select and the combo box still stays open?</p>