Hi,
Sorry. I am not able to reproduce this issue. Could you please show us the code?
I use the following code to test.
private void Form1_Load(object sender, EventArgs e)
{
DataTable dt01 = new DataTable();
dt01.Columns.Add("col01");
dt01.Columns.Add("col02");
dt01.Rows.Add("1","aa");
dt01.Rows.Add("2","bb");
DataTable dt02 = new DataTable();
dt02.Columns.Add("ID");
dt02.Columns.Add("Name");
dt02.Rows.Add("1", "aa");
dataGridView1.AutoGenerateColumns = false;
dataGridView1.DataSource = dt02;
DataGridViewComboBoxColumn cmb = new DataGridViewComboBoxColumn();
cmb.DataSource = dt01;
cmb.DataPropertyName = "ID";
cmb.DisplayMember = "col02";
cmb.ValueMember = "col01";
dataGridView1.Columns.Add(cmb);
}
private void button1_Click(object sender, EventArgs e)
{
Console.WriteLine(dataGridView1.Rows[dataGridView1.Rows.Count - 2].Cells[0].Value.ToString());
}
Best regards,
Ling Wang
Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.