Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using Combobox SelectedIndexChanged event to perform few tasks. It is working nice. But when i am closing the form, SelectedIndexChanged gets fired and i get "Object reference not set to an instance of an object." exception. My code is following-

C#
private void cmbProductName_SelectedIndexChanged(object sender, EventArgs e)
  {
      try
      {
          Product p =(Product) cmbProductName.SelectedItem;

          RawItems = RawItem.GetEntityList(p.Id, ConnectionString);

      }
      catch (Exception ex)
      {
          CustomMessageBox.ShowSystemException(ex);
      }
  }


How to avoid the SelectedIndexChanged event being fired when form is closing?

Thanks
SKPaul.
Posted

1 solution

anything your setting related to cmbProductName in Form Closing event? or may be focus will be there in Combo.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900