Click here to Skip to main content
15,887,318 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, friends..
I have a problem relating to datagridview combobox..

I have a datagridview binded with a customer datatable, one of datagridview columns is combobox which uses student datatable as a datasource (means: datagridViewCombobox.datasource= studentDatatable)..

Now, when the user adds a new row to the datagridview, and selects a student name from the combobox, everything goes fine, and the new row is added to the customer datatable normally..

but, when the user wants to add a new name which isn't one of the student names including in combobox list by typing the name manually, the combobox doesn't accept the new entry and the new row isn't added to the datagridview.

So, how to make the datagridview combobox behaves as a datagridview textbox when the user enters a custom value which doesn't belong the values found in the combobox list. (in other words: how to make datagridview combobox accepts the entering by selecting an item from its list, and in the same time accept the entering manually by the user.)

I use VS 2010..

Thank you so much..

What I have tried:

I tried to make items of the combobox to get added by using items.add(studentNames), and made the datasource property of the combobox to null..
Posted
Updated 13-Nov-19 7:06am

1 solution

Use grid controls cellvaluechanged event for the student column and check if the student exists in the list? if not add the student to the table. and save the grid or save the customer data. Since the student not exist, you cannot add to the customer table? Hope this helps.
 
Share this answer
 
Comments
Mohammad Abdullaha 14-Nov-19 8:03am    
Hi, Member 3751752..
Thanks for your reply, I tried to use the solution you suggested, but the cellvaluechanged event hasn't been fired when I tried to type a name manually and moved outside of the combobox by pressing Tab key, but when I had selected a name from the combobox list, the cellvaluechanged event fired. So, the solution you have suggested hasn't worked 🙁.. Thanks for your attempt.

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