Azox
Azox

Reputation: 1940

Change Datagridview ColumnType from textbox to combobox

I have a GridView with a data source (automatically generated from Visual Studio's designer). The datasource automatically creates the Columns in the GridView, this part is all working fine.

The problem is that i want to change the type of that column from DataGridViewTextBoxColumn to DataGridViewComboBoxColumn, i do that like this:

Screenshot

After changing this, i get an error loading the grid:

System.ArgumentException: DataGridViewComboBoxCell value is not valid.

The type of the column is SQL is varchar(50).

The only code i'm using is to bind the DataSet to the GridView:

this.tasksTableAdapter.Fill(this.tasksDataSet.Tasks, user.ID);

Any advice would be greatly appreciated

Upvotes: 0

Views: 1846

Answers (1)

Azox
Azox

Reputation: 1940

After some more trying i found the answer. I had to select the same DataSource for the ComboBox as i used for the DataGrid. doing this and setting DisplayMember and DataMember, the grid loaded without errors ! :)

Upvotes: 0

Related Questions