Hi Guys,

I currently have this code to load a combobox. I also have a class to set the itemdata and text for each item.

my problem is that when the form loads I have another query that selects a classid for a student. I want to compare the itemdata for each item in the combobox against the current classid for that pupil and then set the selectedindex of the combo where that classid is. How can I do it. Please help.

Code:
Private Sub LoadClassCombo()
        Dim myDataReader As MySqlDataReader

        Using con As New MySqlConnection

            Dim strsql As String = "SELECT classid,CONCAT_WS(' ',gradelevel,class) from classes ORDER BY Gradelevel;"

            Dim cmd As New MySqlCommand

            With cmd
                .Connection = New MySqlConnection(myConnStr)
                .Connection.Open()
                .CommandText = strsql
                myDataReader = .ExecuteReader

            End With

            With cboClass
                .Items.Clear()

                Do While myDataReader.Read
                    .Items.Add(New ComboListData(myDataReader.GetString(1), myDataReader.GetString(0)))
                Loop

            End With

        End Using

    End Sub
class:

Code:
Public Class ComboListData

    Private sName As String
    Private iID As Long

    Public Sub New()
        sName = ""
        iID = 0
    End Sub

    Public Sub New(ByVal Name As String, ByVal ID As Long)
        sName = Name
        iID = ID
    End Sub

    Public Property Name() As String
        Get
            Return sName
        End Get

        Set(ByVal sValue As String)
            sName = sValue
        End Set
    End Property

    Public Property ItemData() As Long
        Get
            Return iID
        End Get

        Set(ByVal iValue As Long)
            iID = iValue
        End Set
    End Property

    Public Overrides Function ToString() As String
        Return sName
    End Function

End Class