获取datagridview的价值 [英] Getting Datagridview value

查看:126
本文介绍了获取datagridview的价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用VB.Net,

在我的应用程序,现在用的DataGridView,当我点击特定行,这行的值应出现在文本框中。

In my application, am using datagridview, when i clicking the particular row, that rows value should be appear in the textbox.

所以,code应该受到的DataGrid3_CellMouseDoubleClick事件。

So the code should be come under the DataGrid3_CellMouseDoubleClick Event.

如何dispaly在文本框中一个行价值。

How to dispaly a rows value in the textbox.

例如

3行指 - 3行中的值应在3个文本框中显示

3 rows means - 3 rows values should display in 3 textbox.

VB6 code

Private Sub datagrid1_DblClick()

    textbox1 = datagrid1.SelectedItem.SubItems(1)
    textbox2 = datagrid1.SelectedItem.SubItems(2)
    textbox3 = datagrid1.SelectedItem.SubItems(3)
End Sub

如何通过获取数据网格行值写一个code在vb.net。

How to write a code in vb.net by getting datagrid row values.

需要VB.Net样品code帮助

Need VB.Net sample code Help

推荐答案

试试这个 - >

Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
Dim i As Integer
i = DataGridView1.CurrentRow.Index
TextBox1.Text = DataGridView1.Item(0, i).Value
TextBox2.Text = DataGridView1.Item(1, i).Value
TextBox3.Text = DataGridView1.Item(2, i).Value
TextBox4.Text = DataGridView1.Item(3, i).Value
End Sub

在这里,我是所选行的rowIndex位置为 DataGridView1.Item(0,I),和数量是细胞指数。

Here i is the RowIndex of the selected row for DataGridView1.Item(0, i), and the number is the cell index.

这篇关于获取datagridview的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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