I pull the data from sql database and fill datagridView1 with it:
dataGridView1.DataSource = bsour;
User will be able to edit value in 1 column, but possible values for that column are only Null, 0, 1 or 2 so to prevent from inputting incorrect value i decided to do a ComboBoxColumn:
DataGridViewComboBoxColumn col1 = new DataGridViewComboBoxColumn();
col1.Name = "il_normal_combo";
col1.HeaderText = "Normal";
col1.Items.Add("");
col1.Items.Add("0");
col1.Items.Add("1");
col1.Items.Add("2");
dataGridView1.Columns.Insert(5, col1);
The other now unnecessary column I'll hide with .Visible = false; I want the ComboBoxColumn to display database values from that other column that will be hidden and i can't seem to get it to work.
What i have tried:
col1.ValueMember = "il_normal";
col1.DisplayMember = "il_normal";
Those don't work but without error message. This doesn't work and produces error "Values are incorrect"
for (int i = 0; i <= dataGridView1.Rows.Count - 1; i++)
{
dataGridView1.Rows[i].Cells[5].Value = dataGridView1.Rows[i].Cells[7].Value;
}