I have a datagridview on a Winforms app where I add a DataGridViewComboBoxColumn. The datagridview is not visible (on a different tab) when the program starts and tries to set the DgvComboBox's value. It appears in my case that the DataGridView combobox's value cannot be set until I go to the tab that contains the Dgv, and gets painted. Then I can go back to the original tab and set the combobox all day long.
dgvRequirements.DataSource = ReqDB.GetNewRequirements()
Dim col As New System.Windows.Forms.DataGridViewComboBoxColumn
col.DropDownWidth = 400
col.DataPropertyName = "Responsible"
col.Name = "Responsible"
col.HeaderText = "Responsible"
col.Items.Add(" ")
col.DataSource = activeEmployees
col.DisplayMember = "Name"
col.ValueMember = "empId"
col.DropDownWidth = 400
dgvRequirements.Columns.Insert(2, col)
The issue is I am trying to set the value of the column programmatically.
dgvRequirements.Rows(index).Cells("Responsible").Value = cboDefault.SelectedValue
The DatagridView is on a different tab. No matter how many times I attempt to set the ComboBox column's value, it will not set, until FIRST I go to the tab where the datagridview is on. Once the Dgv gets painted, and I go back to set the value, then the value can be set without any problem.