[RESOLVED] Data-bound combo box in DataGridView
I have a datagridview bound to one SQL data table. Within that datagridview, I have one cell, Hotel, which is set up as a combo box which has a hotel table as it's datasource. The properties are shown below. My problem: When the user goes to the hotel combobox in the datagrid, if they begin to type in a hotel, even though the autocomplete property is set to false, the combobox does just that. Which will not allow my user to enter a new hotel name - one not in the list that they would then want to add. Any ideas on how I can get the combo box to only suggest hotels (like you could in a normal combo box) or even to not even do that, so that a user could potentially type in a new hotel?
Properties for Hotel column in bound datagridview:
Autocomplete: False
ReadOnly: False
DataPropertyName: Hotel
Datasource: HotelsBindingSource
DisplayMember: HotelScreenName
ValueMember: HotelID
ColumnType: DataGridViewComboBoxColumn
Re: Data-bound combo box in DataGridView
A standard ComboBox has a DropDownStyle property that you can set to DropDown or DropDownList. One allows the user to enter any value and the other requires them to select from the list. A ComboBox in a DataGridView acts like a standard ComboBox with its DropDownStyle set to DropDownList, i.e. it requires that the user make a selection from the list. That's because it's the SelectedValue of the ComboBox that corresponds to the Value of the cell. If the user could enter any old value then there would be no corresponding entry in the ValueMember column so the cel couldn't have a value. That situation makes no sense so it is prohibited. You can create your own column types or customise the existing ones if you want something different but it is not for the faint-hearted.
Re: Data-bound combo box in DataGridView
Thank you for the great explanation.