How to set Cell value of DataGridViewRow by column name?

后端 未结 5 733
小蘑菇
小蘑菇 2020-12-15 20:51

In windows forms, I\'m trying to fill a DataGridView manually by inserting DataGridViewRows to it, so my code looks like this:

Data         


        
5条回答
  •  粉色の甜心
    2020-12-15 21:20

    I tried it too and got the same result. This is a little verbose, but it works:

    row.Cells[dataGridView1.Columns["code"].Index].Value = product.Id;
    

提交回复
热议问题