如何在datagridview
VB.net中对textbox
列标题和列值进行求和按datagridview
列使用的值(For& Next)?
示例
在datagridview
:之前
column : ID address
1 street1
2 street2
3 street3
在textbox
:之后
ID = 1 / address = street1
ID = 2 / address = street2
ID = 3 / address = street3
答案 0 :(得分:0)
这一小段代码会将值添加到列表中,您可以从中填充文本框。它假定未知数量的列,dgv是您的DataGridView:
Dim txtBoxList As New List(Of String)
Dim strLine As String
For Each dgvRow As DataGridViewRow In dgv.Rows
For i As Integer = 0 To dgv.Columns.Count - 1
strLine = strLine & String.Format("{0} = {1}", dgv.Columns(i).HeaderText.ToString, dgvRow.Cells(i).tostring)
If i < dgv.Columns.Count - 1 Then
strLine = strLine & " / "
End If
Next
txtBoxList.Add(strLine)
strLine = String.Empty
Next