My DataGridView contains three columns, column types are checkbox, textbox and combobox.
How can I load a row's combobox when the checkbox in the same row is checked?
maybe this could help (example)
Dim dgvcc As DataGridViewComboBoxCell
dgvcc = DataGridView1.Rows(2).Cells(0)
dgvcc.Items.Add("comboitem1")
dgvcc.Items.Add("comboitem2")
You can bind like this -
Dim dtRange As DataTable = GetQueryTable("select range_name from table_name")
Me.grid_column_name.ValueMember = "range_name"
Me.grid_column_name.DisplayMember = "range_name"
Me.grid_column_name.DataSource = dtRange
and this will bind table record to complete DataGridViewColumn of DataGridView.
Another approach is to filter the Datasource (in my case a dataset) when you edit another column that needs to filter the combobox column. I find this super easy to code and efficient.
Private Sub DGV_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs) Handles DGV.CellBeginEdit
Select Case e.Column.Name
Case "TabID"
Me.FormTabBindingSource.RemoveFilter()
Me.FormTabBindingSource.Filter = String.Format("FormID = {0}", DGV.Rows(e.RowIndex).Cells("FormID").Value)
End Select
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.