将DataGridView1添加到Listbox1 VB.net
快速提问,或者我希望它是快速的 我有一个包含4列的DataGridView1,我想将DataGridView1上的所有内容都添加到列表框中 列示例将DataGridView1添加到Listbox1 VB.net,vb.net,Vb.net,快速提问,或者我希望它是快速的 我有一个包含4列的DataGridView1,我想将DataGridView1上的所有内容都添加到列表框中 列示例 Name Average Handicap Paid John 170 0 20 Alex 180 0 15 Jane 200 0 10 Jim 150 0 20 当我单击按钮1时,我希望它
Name Average Handicap Paid
John 170 0 20
Alex 180 0 15
Jane 200 0 10
Jim 150 0 20
当我单击按钮1时,我希望它沿着行向下移动,并将它们添加到列表框1中
ListBox1示例
John Paid $20
Alex Paid $15
Jane Paid $10
Jim Paid $20
我已经设置了DataGridView1,如果单击它,它将填充一些标签,并希望有一种方法可以一次自动选择每一行,只需拉标签。文本信息会自动向下滚动列表,但不知道如何一次自动选择一个列表
谢谢在
按钮1中单击事件
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
For i As Integer = 0 To DataGridView1.Rows.Count - 1
Dim LboxValue As String = DataGridView1.Rows(i).Cells(0).Value & " " & DataGridView1.Columns(3).HeaderText & " " & DataGridView1.Rows(i).Cells(3).Value
ListBox1.Items.Add(LboxValue)
Next
End Sub
根据你的需要
希望有帮助。您可以在网格的行中循环,并像填充标签一样获得一个值,然后将该值添加到列表框中。标签本身不起作用。您应该有一个方法,可以传递一个网格行并获取值,然后在填充标签
和列表框
时调用该方法。我想我缺少的是e As System.EventArgs。这很有效,谢谢!!!