循环通过datagridview [英] looping through datagridview

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

问题描述

我是一个Windows应用程序。包含名为BOM nd BOMSelected的表单。



在BOM中有datagridview,其中包含复选框列。当用户选中复选框时,所选行应该在datagridview中看到其他形式,SelectedBom ..



我有编码,但不能得到它的工作..一些错误..



<你可以帮忙吗?



您的帮助非常感谢..



这是我有完成!!

 公共类SelectedBom 

Private Sub SelectedBom_Load(ByVal sender As System.Object,ByVal e As System.EventArgs)处理MyBase.Load
'TODO:这行代码将数据加载到'HemDatabase1DataSet4.partno'表中。您可以根据需要移动或移除它。
'Me.PartnoTableAdapter.Fill(Me.HemDatabase1DataSet4.partno)

Dim count As Integer = 0

对于j As Integer = 0到BOM.dgv1。 RowCount - 1

如果BOM.dgv1.Rows(j).Cells(0).Value = True然后

Dim ro As New DataGridViewRow
DataGridView2.Rows .Add(ro)

对于i As Integer = 0 To BOM.dgv1.ColumnCount - 1
Me.DataGridView2.Rows(count).Cells(i).Value = BOM.dgv1 .Rows(j).Cells(i).Value
Next

count + = 1

如果

下一张

End Sub
结束类


解决方案

可能不是使用每个语句,而应该使用:

  fortep as integer = 0 to datagridview。 rowcount  -  2 

对于每种语法,您不能分配值当您沿着行走时,到单独的行。


Mine is a windows app. containing forms named BOM nd BOMSelected..

There is datagridview in BOM which contains checkbox column.. When the user selects checkbox, the selected rows should be seen in the datagridview of other form, SelectedBom..

I have coded but don't get it working.. Some error..

Can you please help ??

Your Help is greatly appreciated..

Here is what i have done !!

Public Class SelectedBom

    Private Sub SelectedBom_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'HemDatabase1DataSet4.partno' table. You can move, or remove it, as needed.
        'Me.PartnoTableAdapter.Fill(Me.HemDatabase1DataSet4.partno)

        Dim count As Integer = 0

        For j As Integer = 0 To BOM.dgv1.RowCount - 1

            If BOM.dgv1.Rows(j).Cells(0).Value = True Then

                Dim ro As New DataGridViewRow
                DataGridView2.Rows.Add(ro)

                For i As Integer = 0 To BOM.dgv1.ColumnCount - 1
                    Me.DataGridView2.Rows(count).Cells(i).Value = BOM.dgv1.Rows(j).Cells(i).Value
                Next

                count += 1

            End If

        Next

    End Sub
End Class

解决方案

Maybe instead of using the for each statement, you should instead use:

for istep as integer = 0 to datagridview.rowcount - 2

With the for each syntax, you can't assign a value to the individual row as you walk down the row.

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

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