E
Earl
I can bind an arraylist to a combobox without a "late binding" error, but I
cannot get to the value directly. Because?
For example, I create an public arraylist of employee objects in the module
(note the Employee is a separate class with the 4 properties being
assigned). I can then bind that arraylist to a combo AND assign the
EmployeeID as a valuemember to the combo, but can NOT pull that value
directly for a comparison. I'm not sure why or what the error is telling me
about the "late binding" in the second case.
***************************************
Public EmployeeList As New ArrayList
Public Sub PopulateEmployees()
Dim intEmpID As Int32
Dim strEmpFirst As String
Dim strEmpMiddle As String
Dim strEmpLast As String
EmployeeList.Clear()
Dim strEmployees As String = "SELECT * FROM OurPersonnel"
Dim strSQLServer As New SqlConnection(strConnString)
Dim daEmployees As New SqlDataAdapter(strEmployees, strSQLServer)
daEmployees.Fill(dsWinMatrix, "dtEmployees")
Dim EmployeeDataView As New
DataView(dsWinMatrix.Tables("dtEmployees"))
Dim intCounter As Int32 = EmployeeDataView.Count
For intCounter = 0 To intCounter - 1
intEmpID = EmployeeDataView.Item(intCounter).Item("EmployeeID")
strEmpFirst =
EmployeeDataView.Item(intCounter).Item("EmployeeFirstName")
strEmpMiddle =
EmployeeDataView.Item(intCounter).Item("EmployeeMiddleInitial")
strEmpLast =
EmployeeDataView.Item(intCounter).Item("EmployeeLastName")
EmployeeList.Add(New Employee(intEmpID, strEmpFirst,
strEmpMiddle, strEmpLast))
Next
End Sub
......................
'no problems here
cmbEmployee.DisplayMember = ToString()
cmbEmployee.ValueMember = "EmployeeID"
cmbEmployee.DataSource = EmployeeList
....................
'late binding error here with Option Strict ON
If IsDBNull(dsFoundRow("ConfirmEntryEmpID")) = False Then
'error on THIS line
If dsFoundRow("ConfirmEntryEmpID") =
EmployeeList.Item(intCounter).EmployeeID Then
cmbConfirmEmployee.Text = EmployeeList.Item(intCounter).ToString
End If
Else : cmbConfirmEmployee.Text = ""
End If
cannot get to the value directly. Because?
For example, I create an public arraylist of employee objects in the module
(note the Employee is a separate class with the 4 properties being
assigned). I can then bind that arraylist to a combo AND assign the
EmployeeID as a valuemember to the combo, but can NOT pull that value
directly for a comparison. I'm not sure why or what the error is telling me
about the "late binding" in the second case.
***************************************
Public EmployeeList As New ArrayList
Public Sub PopulateEmployees()
Dim intEmpID As Int32
Dim strEmpFirst As String
Dim strEmpMiddle As String
Dim strEmpLast As String
EmployeeList.Clear()
Dim strEmployees As String = "SELECT * FROM OurPersonnel"
Dim strSQLServer As New SqlConnection(strConnString)
Dim daEmployees As New SqlDataAdapter(strEmployees, strSQLServer)
daEmployees.Fill(dsWinMatrix, "dtEmployees")
Dim EmployeeDataView As New
DataView(dsWinMatrix.Tables("dtEmployees"))
Dim intCounter As Int32 = EmployeeDataView.Count
For intCounter = 0 To intCounter - 1
intEmpID = EmployeeDataView.Item(intCounter).Item("EmployeeID")
strEmpFirst =
EmployeeDataView.Item(intCounter).Item("EmployeeFirstName")
strEmpMiddle =
EmployeeDataView.Item(intCounter).Item("EmployeeMiddleInitial")
strEmpLast =
EmployeeDataView.Item(intCounter).Item("EmployeeLastName")
EmployeeList.Add(New Employee(intEmpID, strEmpFirst,
strEmpMiddle, strEmpLast))
Next
End Sub
......................
'no problems here
cmbEmployee.DisplayMember = ToString()
cmbEmployee.ValueMember = "EmployeeID"
cmbEmployee.DataSource = EmployeeList
....................
'late binding error here with Option Strict ON
If IsDBNull(dsFoundRow("ConfirmEntryEmpID")) = False Then
'error on THIS line
If dsFoundRow("ConfirmEntryEmpID") =
EmployeeList.Item(intCounter).EmployeeID Then
cmbConfirmEmployee.Text = EmployeeList.Item(intCounter).ToString
End If
Else : cmbConfirmEmployee.Text = ""
End If