如何将gridview列中的数据放入不同的文本框中 [英] How do I put data in gridview columns into different textbox

查看:89
本文介绍了如何将gridview列中的数据放入不同的文本框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望将gridview中的数据输出到文本框。我的gridview中有多行单元格。



我的代码使用一个按钮将数据输出到文本框。我想要textbox1中第一列和textbox2中下一列的数据。



我编写的代码输出Textbox1中的第一行,第一行和第一行。 Textbox2中的第2名,第1名&第二& Textbox3等中的第3个...



我遇到的问题是我想在textbox2中的textbox1第2列中的第1列(向下)等任何帮助都很大赞赏





对此的任何帮助都会很棒



我尝试了什么:



循环遍历行和列

解决方案

只是一个猜测:



 对于k As Integer = 0到dv.Count  -  1 
strTemp& = dv(k )(TxtDat)。ToString.PadRight(50,)& vbCrLf
下一步





 strTemp = dv(i)(TxtDat) .ToString.PadRight(50,)& vbCrLf 


也猜这里......



我愿意;

1)获取datagridview数据源(最好是作为DataTable)

2)迭代列或行。



< pre lang =vb> Dim dataTable As DataTable = TryCast (dgv.DataSource,DataTable)

对于 每个 column As DataColumn In dataTable.Columns
For 每个 dRow as DataRow in dataTable.Rows
TextBox1.Text = dRow [column]
退出
退出





您将需要做更多的事情调试,但这是IMO的主旨。


I am looking to output the data in my gridview to textboxs. I have multiple rows an cells in my gridview.

I have code that uses a button which outputs Data to a textbox. I want the data in the first column in textbox1 and next column in textbox2.

The code I wrote outputs the first row accross in Textbox1, the 1st & 2nd in Textbox2, the 1st & 2nd & 3rd in Textbox3 etc...

The problem I have with it is I want column 1 (going down) in textbox1 column 2 in textbox2 etc. Any help is greatly appreciated


any help on this would be great

What I have tried:

looping through rows and columns

解决方案

Just a guess:

For k As Integer = 0 To dv.Count - 1
  strTemp &= dv(k)("TxtDat").ToString.PadRight(50, " ") & vbCrLf
Next



strTemp = dv(i)("TxtDat").ToString.PadRight(50, " ") & vbCrLf


Also guessing here...

I would;
1) Get the datagridview datasource (preferably as a DataTable)
2) Iterate columns or rows.

Dim dataTable As DataTable = TryCast(dgv.DataSource, DataTable)

For Each column As DataColumn In dataTable.Columns
    For Each dRow as DataRow in dataTable.Rows
       TextBox1.Text = dRow[column]
    Exit
Exit



You will have to do a lot more debugging, but this is the jist of it IMO.


这篇关于如何将gridview列中的数据放入不同的文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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