我正在将下面的代码与COM接口对象一起使用。
Public Shared Sub ExportPa(ByVal mdl As IScrModel, ByVal dgv As DataGridView)
Try
dgv.Rows.Clear()
If mdl.findElement(My.Settings.str_elem__subvar_grpname_pa, False) IsNot Nothing Then
Dim grpList As IScrSubVarGroup = CType(mdl.findElement(My.Settings.str_elem__subvar_grpname_pa, False), IScrSubVarGroup)
For i As Integer = 0 To grpList.getSubvarList(True).count - 1
Dim obj As IScrSubVar = CType(grpList.getSubvarList(True).item(i), IScrSubVar)
Dim countRow As Integer = dgv.RowCount
If obj.intent.val = IntentStatusCBO() Then
Select Case obj.get_discr_str.Length
Case Is > 1
dgv.Rows.Add(countRow, obj.fullName.Substring(My.Settings.str_elem__subvar_grpname_pa.Length + 1), "discr")
Dim cbCell As New DataGridViewComboBoxCell
cbCell = CType(dgv.Rows(countRow).Cells(3), DataGridViewComboBoxCell)
cbCell.Items.Clear()
For iIndex = 0 To UBound(obj.get_discr_desc())
cbCell.Items.Add(obj.get_discr_desc().GetValue(iIndex))
cbCell.Value = obj.discr_desc(Array.IndexOf(obj.get_discr_str(), obj.str.src)).src
Next
Case Else
dgv.Rows.Add(countRow, obj.fullName.Substring(My.Settings.str_elem__subvar_grpname_pa.Length + 1), "std")
End Select
End If
Next
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
在以下代码中,我想将接收自对象“ obj.get_discr_desc()”的数组添加到我的comboboxcell中。每个对象的数组都有不同的数组,所以我必须逐个单元格地添加。该代码现在工作良好,但我不知道这是正确的方法吗?
Dim cbCell As New DataGridViewComboBoxCell
cbCell = CType(dgv.Rows(countRow).Cells(3), DataGridViewComboBoxCell)
cbCell.Items.Clear()
For iIndex = 0 To UBound(obj.get_discr_desc())
cbCell.Items.Add(obj.get_discr_desc().GetValue(iIndex))
cbCell.Value = obj.discr_desc(Array.IndexOf(obj.get_discr_str(), obj.str.src)).src
Next