开发者

Get value from a cell in DataGridView into a TextBox when using BindingNavigator

I want to populate 开发者_C百科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();


To get the current row use the dataGridView1.CurrentCell.RowIndex property value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜