vb.netdatagridviewcomboboxcolumn

How to retype the DataGridViewComboBoxColumn in VB.NET?


enter image description here

I hope, users can type text directly into the combobox. And then when the dropdown button is clicked, a Form will appear(instead of the usual dropdown menu.) Please help me.


Solution

  • You'd have to create your own custom column, cell and editing control to make it worthwhile. You can handle the EditingControlShowing event of the grid and configure the ComboBox editing control to allow entering arbitrary text by setting the DropDownStyle property to DropDown instead of DropDownList, but it will do you little good. That's because, the way the standard column works, the Value of the cell is copied to the SelectedValue of the editing control when you start editing a cell and then back again when you finish. As it stands, any text you enter would simply be ignored. Your custom cell and editing control would have to handle the fact that an item from the drop-down list may or may not be selected and your custom column would have to use the custom cell as its template. It's doable but it's far from trivial. If you're up for the challenge then you had better start researching custom DataGridView columns and how to create them.