Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net DataGridView中的ComboBox如何填充第二列中的另一个ComboBox_Vb.net_Winforms_Datagridview - Fatal编程技术网

Vb.net DataGridView中的ComboBox如何填充第二列中的另一个ComboBox

Vb.net DataGridView中的ComboBox如何填充第二列中的另一个ComboBox,vb.net,winforms,datagridview,Vb.net,Winforms,Datagridview,晚上好,我在使用DataGridComboBox填充DataGridView中的记录时遇到问题 这是我想要的,但我得不到 我在DataGridView1中创建了datagridcomboxcolumn,在组合框下拉列表中有两个项目。如果我在组合框列中选择“机器”。它将在下一个单元格中添加另一个ComboBoxColumn,其中包含两项-“机器1”、“机器2”。此外,如果我选择“材料”,它将更改“材料1”和“2”中的项目 任何人都可以帮我,非常感谢。谢谢。试试下面的代码 Dim sourceGri

晚上好,我在使用DataGridComboBox填充DataGridView中的记录时遇到问题

这是我想要的,但我得不到

我在
DataGridView1
中创建了
datagridcomboxcolumn
,在
组合框下拉列表中有两个项目。如果我在
组合框
列中选择
“机器”
。它将在下一个单元格中添加另一个
ComboBoxColumn
,其中包含两项-
“机器1”、“机器2”
。此外,如果我选择
“材料”
,它将更改
“材料1”
“2”
中的项目

任何人都可以帮我,非常感谢。谢谢。

试试下面的代码

Dim sourceGrid As DataGridView = Me.DataGridView1
Dim targetGrid As DataGridView = Me.DataGridView2

Dim targetRows = New List(Of DataGridViewRow)
For Each sourceRow As DataGridViewRow In sourceGrid.Rows
    If (Not sourceRow.IsNewRow) Then
        Dim targetRow = CType(sourceRow.Clone(), DataGridViewRow)
       For Each cell As DataGridViewCell In sourceRow.Cells
            targetRow.Cells(cell.ColumnIndex).Value = cell.Value
        Next
        targetRows.Add(targetRow)
    End If
Next
targetGrid.Columns.Clear()
For Each column As DataGridViewColumn In sourceGrid.Columns
    targetGrid.Columns.Add(CType(column.Clone(), DataGridViewColumn))

下一步

请检查,我会检查一下,先生。谢谢分享。您好,DBGetData(“选择…”)有一个错误。好吧,由于没有代码来理解您的逻辑,我能提供的最好帮助是提供一些有用的链接来指导您。您提供的第二个链接中的代码是我需要的逻辑,但我无法确定DBGetData来自何处。