Datagridview到详细的行选择 [英] Datagridview to detailed on row select

查看:101
本文介绍了Datagridview到详细的行选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

只是对datagridviews提出疑问并绑定数据源.

我有一个具有绑定数据源的datagridview的窗体(FORMA),当用户单击datagrid中的选定行时,我希望它在详细视图(文本框)中以新窗体(FORMB)打开该选定记录.

由于我的编码能力有限,请有人概述一下该如何完成.

谢谢

Hi All,

Just have a questiion regarding datagridviews and bind data source.

I have a form (FORMA) that has a datagridview with bound data source, when a user clicks on a selected row in the datagrid, i want it to open that selected record in a new form (FORMB)in a detailed view (textbox)

Please could someone outline how this can be complete, as my coding skills are limited.

Thanks

推荐答案

希望这会有所帮助,


在DataGridView1_clickCell事件下添加以下代码.

DataGridViewRow行= dataGridView1.Rows [e.RowIndex];
textBox1.Text = row.Cells [0] .Value.ToString();
textBox2.Text = row.Cells [1] .Value.ToString();

等等.

这将用您在DataGridView中双击的行值填充文本框.
Hope this might help,


Under DataGridView1_clickCell event add the following codes.

DataGridViewRow row = dataGridView1.Rows[e.RowIndex];
textBox1.Text = row.Cells[0].Value.ToString();
textBox2.Text = row.Cells[1].Value.ToString();

and so on.

This vill populate the text box with the row values that you double clicked in the DataGridView.


对于初学者来说简单的方法
在< code> DataGridView1_clickCell</code>下,事件添加以下代码.
< pre> DataGridViewRow行= dataGridView1.Rows [e.RowIndex];
昏暗的form2作为新形式
form2.show()
form2.textbox1.text ="row.Cells [1] .Value.ToString();"
form2.textbox1.text =" row.Cells [1] .Value.ToString();"
</pre>
easy way for beginers
Under <code>DataGridView1_clickCell</code> event add the following codes.
<pre>DataGridViewRow row = dataGridView1.Rows[e.RowIndex];
dim form2 as new form
form2.show()
form2.textbox1.text="row.Cells[1].Value.ToString();"
form2.textbox1.text= "row.Cells[1].Value.ToString();"
</pre>


这篇关于Datagridview到详细的行选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆