int index = DataGridView1.CurrentRow.Index; //取得选中行的索引
txt_ProductId.Text = DataGridView1.Rows[index].Cells["Id"].Value; //获取单元格列名为‘Id’的值