Combo box is not displaying default value in DataGridView in C#

前端 未结 3 1357
时光说笑
时光说笑 2021-01-20 18:21

I\'m trying to allow user to select value from DataGridViewComboBoxColumn for each new row. I\'ve bound ComboBox in GridView to databa

3条回答
  •  囚心锁ツ
    2021-01-20 19:09

    bindingSource1.DataSource = itemBAL.GetTable();
    dataGridView1.DataSource = bindingSource1; 
    ItemName.DataSource = bindingSource1; //Where ItemName is an instance ofDataGridViewComboBoxColumn
    ItemName.DisplayMember = "Name";
    ItemName.ValueMember = "ItemId";
    

    add this line only

    dataGridView1["ItemName",dataGridRowNumber].value=1;//item id value
    

提交回复
热议问题