Topic Introduction:
I recently noticed, that when you use the DataGridViewColumn-Class to create a DataGridViewComboBoxColumn inside of a DataGridView this "ComboBox" will behave differently from a familiar ComboBox behaviour of a ComboBos created with the System.Windows.Forms.Control-Class.
When you click a traditional ComboBox, a DropDownMenu opens, this also works with the DataGridViewComboBoxColumn-ComboBos but seems a little bit delayed.
When you double-click a traditional ComboBox you can enter your own text and when you press enter afterwards this own text will display in the ComboBox instead of a selected text out of the pre-determined texts inside the DropDownMenu of the ComboBox.
To come to my specific problem:
When I use a DataGridViewComboBoxColumn-ComboBox and double click on it I will not have the abiity to create a own text, the ComboBox will display afterwards.
What I did:
I tried to search for this problem in the internet using different words for describing both the problem and/or a possible solution but I did not find the exact same problem. Most of the threads had questions like "How to use a ComboBox inside a DataGridView" and the answers varied from "Use a DataGridViewComboBoxColumn" to "Draw your own ComboBox using the ComboBoxRenderer-Class". I found lots of code examples but NONE had the ability to do what I described above".
What I hope for:
If you have or had experience with this kind of problem or even the specific problem I mentioned, it would be very helpfull if you could share your thoughtprocess about the problem no matter you solved the problem or not. Any thoughts and ideas could guide me to a solution.
Thank you !
Look at this post. Follow the code that will let you add a new value to list if it is not there.
Ensure that the EditMode property of the DataGridView is set to EditOnKeystrokeOrF2
and
ReadOnly
property is set to False.