Click here to Skip to main content
Rate this: bad
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)
            Product p =(Product) cmbProductName.SelectedItem;
            RawItems = RawItem.GetEntityList(p.Id, ConnectionString);
        catch (Exception ex)
How to avoid the SelectedIndexChanged event being fired when form is closing?
Posted 6-Nov-12 1:12am

1 solution

Rate this: bad
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.

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

  Print Answers RSS
0 /\jmot 230
1 Zoltán Zörgő 210
2 CHill60 145
3 Peter Leow 145
4 Sergey Alexandrovich Kryukov 125
0 Sergey Alexandrovich Kryukov 9,353
1 OriginalGriff 6,881
2 Peter Leow 4,577
3 Zoltán Zörgő 4,129
4 Richard MacCutchan 2,882

Advertise | Privacy | Mobile
Web02 | 2.8.150129.1 | Last Updated 6 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100