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

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -