Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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-
 
  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 6-Nov-12 0:12am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Shai Vashdi 339
1 Sergey Alexandrovich Kryukov 285
2 OriginalGriff 280
3 Peter Leow 171
4 Abhinav S 168
0 Sergey Alexandrovich Kryukov 8,979
1 OriginalGriff 5,280
2 Peter Leow 4,010
3 Maciej Los 3,535
4 Abhinav S 3,263


Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 6 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid