In my DataGridView there are 3 columns which are Textbox, Textbox and Combobox. I'm trying to add values to that row's combobox. But i can't find the current row because it returns me an error and says it's null. I don't how to handle this.
Public Shared Sub ListSubvarsPA(ByVal mdl As IScrModel, ByVal dgvStd As DataGridView, ByVal dgvDiscr As DataGridView)
dgvStd.Rows.Clear()
dgvDiscr.Rows.Clear()
Dim grpName As String = My.Settings.str_elem__subvar_grpname_pa
If mdl.findElement(grpName, False) IsNot Nothing Then
Dim grpList As IScrSubVarGroup = CType(mdl.findElement(grpName, False), IScrSubVarGroup)
Dim objList As IScrNamedObjectList = grpList.getSubvarList(True)
For i As Integer = 0 To objList.count - 1
Dim obj As IScrSubVar = CType(objList.item(i), IScrSubVar)
Select Case obj.get_discr_str.Length
Case Is > 1
Dim itemindex As Integer = Array.IndexOf(obj.get_discr_str(), obj.str.src)
dgvDiscr.Rows.Add(obj.fullName.Substring(grpName.Length + 1), obj.discr_desc(itemindex).src)
Dim cbCell As New DataGridViewComboBoxCell
cbCell = CType(dgvDiscr.Rows(dgvDiscr.CurrentRow.Index).Cells(2), DataGridViewComboBoxCell)
cbCell.Items.Clear()
For iIndex = 0 To UBound(obj.get_discr_desc())
cbCell.Items.Add(obj.get_discr_desc().GetValue(iIndex))
Next
Case Else
dgvStd.Rows.Add(obj.fullName.Substring(grpName.Length + 1), obj.str.src)
End Select
Next
End If
End Sub
In here it's the problem section for me to add values to existing DataGridViewCombobox values because of i couldn't find the latest row.
Dim itemindex As Integer = Array.IndexOf(obj.get_discr_str(), obj.str.src)
dgvDiscr.Rows.Add(obj.fullName.Substring(grpName.Length + 1), obj.discr_desc(itemindex).src)
Dim cbCell As New DataGridViewComboBoxCell
cbCell = CType(**dgvDiscr.Rows(dgvDiscr.CurrentRow.Index**).Cells(2), DataGridViewComboBoxCell)
cbCell.Items.Clear()
For iIndex = 0 To UBound(obj.get_discr_desc())
cbCell.Items.Add(obj.get_discr_desc().GetValue(iIndex))
Next
Problem occurs in here
Dim cbCell As New DataGridViewComboBoxCell
cbCell = CType(dgvDiscr.Rows(dgvDiscr.CurrentRow.Index).Cells(2), DataGridViewComboBoxCell)