c# - Combo Box selected Item gives Exception -


i have combobox following items:

1024 2048 4096 8192 

i using following code retrive item selected user:

string cach = form.combocache.selecteditem.tostring(); 

but line giving exception null reference exception, object reference not set instance of object

if line giving nullreferenceexception 1 of following true:

  • form null
  • form.combocache null
  • form.combocache.selecteditem null

either reason code work out of case, or put breakpoint on line , debug it, @ form in watch window.

once you've worked out part null, need step , work out why it's null - because presumably expecting not null. don't have enough context here work out (we don't know kind of app you're writing - web, winforms etc) - it'll obvious debugger.


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -