Click here to Skip to main content
15,882,017 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
My form has the combobox which reads the user input , i want to allow the user to enter his own choice apart from the once in the dropdown list.When i run the application i am getting the exception object reference not set to an instance of object.

What I have tried:

i have set the following properties
AutoCompleteCustomSource to Collection
AutoCompleteMode to SuggestAppend
AutoCompleteSource to CustomSource
Posted
Updated 16-Feb-17 20:04pm

object reference not set to an instance of object.

Then you need to use your debugger to find out where and why. It is impossible for anyone to guess which variable in your code is not being initialised correctly.
 
Share this answer
 
i got the solution just by setting combobox.Text="string name" instead of using combobox.SelectedItem.Tostring().
 
Share this answer
 
Comments
Philippe Mori 18-Feb-17 10:07am    
That answer does not make any sense. You are replacing code is reading text with code that is writing text. And obviously if you use SelectedItem then you must be sure that one item is selected. By the way, the debugger would immediately show you the line where the exception occurs and then it is almost trivial to figure out the problem.

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