I want to populate some text boxes while clicking the next row on the BindingNavigator
.
I can use for the first text box:
textBox1.Text = dataGridView1.CurrentCell.Value.ToString();
but I also want to get the info from cells 2 and 3 into textBox2
and textBox3
. How can I access these based on what row is currently selected?
Try This
textBox1.Text = dataGridView1.CurrentRow.Cells["Column name"].Value.ToString();
OR
textBox1.Text = dataGridView1.CurrentRow.Cells[Column index].Value.ToString();
要获取当前行,请使用dataGridView1.CurrentCell.RowIndex
属性值。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.