I have been trying to figure this out for a while and have found some answers, but I can't seem to make them work.
I have a datagridview bound to a datatable. I want replace one of the cells with a combo box and bind that combobox to one of the columns in the datatable. I have been able to replace the cell OK but currently have two issues I have not been able to resolve.
1. When I add items to the drop down (items.add ("Yes")...) they don't appear in the drop down box.
2. I can't figure out the syntax to bind a particular column in my datatable to the newColumn(combobox) in the datagridview.
Any help would be greatly appreciated!!
dbConnection = New OleDbConnection cmdCommand = New OleDbCommand Try dbConnection.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = Nosework.mdb" strSQL = "SELECT * FROM Competitors" cmdCommand.CommandText = strSQL cmdCommand.Connection = dbConnection dbConnection.Open() drDataReader = cmdCommand.ExecuteReader dtCompetitor = New DataTable dtCompetitor.Load(drDataReader) dbConnection.Close() dgInShow.DataSource = dtCompetitor Catch ex As Exception MsgBox(ex.Message) End Try Dim newColumn As New DataGridViewComboBoxColumn With newColumn .Name = "InShow" .HeaderText = "In Show" .Width = 50 .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight .ReadOnly = True .Visible = True .DefaultCellStyle.BackColor = Color.White .Items.Add("Yes") .Items.Add("No") End With dgInShow.Columns.Add(newColumn)