I need to add a new item to a windows form application combo box without touching the datasource, like we add it in a web application, using Items.Insert(index, newItem).
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would think this would do the trick – after you bind the data source to the ComboBox, add the additional items:
Are you having problems getting that to work?
EDIT
Did some research via google – turns out you can’t add items after the ComboBox is databound. You have to add the items to the datasource itself. For example, say you’re binding a DataTable to the ComboBox, with the DisplayMember set to column 1 and the ValueMember set to column 0: