Try setting the SelectedValue
property:
comboBoxCnAceptaPromociones.SelectedValue =
Convert.ToBoolean(cliente.Cells["cnAceptaPromociones"].Value);
سؤال
The thing im trying to do is to get the value from a datagridview table already populated, to an editing phase, textbox are filling nicely but I cant find a way to assign the value of the table to a combobox item.
private void button2_Click(object sender, EventArgs e)
{
DataGridViewRow cliente = dataGridView1.CurrentRow;
textBoxDsClave.Text = cliente.Cells["dsClave"].Value.ToString();
textBoxDsRazonSocial.Text = cliente.Cells["dsRazonSocial"].Value.ToString();
comboBoxCnAceptaPromociones = cliente.Cells["cnAceptaPromociones"].Value.ToString(); //THIS ONE
}
Extra info, the data type of "cnAceptaPromociones" is bool, so it just has either "true" or "false".
I'm really new to C#, and i'm having a hard time learning.
المحلول
Try setting the SelectedValue
property:
comboBoxCnAceptaPromociones.SelectedValue =
Convert.ToBoolean(cliente.Cells["cnAceptaPromociones"].Value);