Programmatically determining selected index of combobox produces null error

From: polynomial5d (anonymous_at_discussions.microsoft.com)
Date: 05/15/04


Date: Fri, 14 May 2004 22:06:02 -0700

Programmatically determining selected index of combobox produces null error

Below is one example of what I tried. Subsequently I update the database in the submitupdate button. My scheme is adapted from ADO.NET Core Reference Chapters 13 and 11.

If I click the combobox to the same values already there, it works fine. That's not such a burden but it seems to me I ought to be able to determine the selected index programmatically.

Any help would be appreciated.

polynomial5d

 Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
        cm.EndCurrentEdit()
        If cboPubFreq.SelectedIndex = -1 Then
            cboPubFreq.SelectedIndex = 1
        ElseIf cboPubFreq.SelectedIndex = cm.Count - 1 Then
            cboPubFreq.SelectedIndex = 1
        Else
            cboPubFreq.SelectedIndex = cboPubFreq.SelectedIndex + 1
        End If
        If cboPublicationType.SelectedIndex = -1 Then
            cboPublicationType.SelectedIndex = 1
        Else
            cboPublicationType.SelectedIndex = cboPublicationType.SelectedIndex
        End If
        If cboContentRights.SelectedIndex = -1 Then
            cboContentRights.SelectedIndex = 1
        Else
            cboContentRights.SelectedIndex = cboContentRights.SelectedIndex
        End If
        If cboPointOfView.SelectedIndex = -1 Then
            cboPointOfView.SelectedIndex = 1
        Else
            cboPointOfView.SelectedIndex = 1
        End If
        SetEditMode(False)
    End Sub


Loading