Quote Originally Posted by Chrissy View Post
I am having trouble displaying the information in the CB. I can retrieve the data fine, just can't populate the combobox using the index.

Is there a way around not having a selectedindex? Would using ENUM work? (not really sure how to do this either!)

I will take a look at the link. Thank you.
I figured it out... here is my code for future reference.

Code:
        Dim db As New DataAccess.sqlDataBase("hp_accting")
        
        Try
            dtgAllocation.Columns.Add("Description", "Taxable Income/(Loss)")

            Dim reader As SqlClient.SqlDataReader = db.GetRecords("Tax_allocation", , , "allocation_code")

            While reader.Read
                dtgAllocation.Rows.Add(reader.Item("allocation_name"))
                xRow = xRow + 1
            End While

            reader.Close()
            dtgAllocation.Update()

            reader = db.GetRealtedRecords("ownership o", "partner p", "p.ocode", "o.ocode",
                                                "p.name, o.ocode", "Tax_projection = '" & cmbYear.Text &
                                                "' AND entity_num = '" & cmbEntity.Text.Substring(0, 8).Trim & "'", "p.ocode")
            'This loads the partner
            If reader.HasRows Then

                While reader.Read
                    xColCount = xColCount + 1
                    Dim cmb As New DataGridViewComboBoxColumn()
                    cmb.Name = reader.Item("ocode").ToString
                    cmb.HeaderText = reader.Item("name")
                    cmb.MaxDropDownItems = 3
                    'Got rid of value member in order to use "Item"
                    cmb.Items.Add("Direct")
                    cmb.Items.Add("Indemnification")
                    cmb.Items.Add("Other")
                    dtgAllocation.Columns.Add(cmb)
                    xRow = 0

                    dtgAllocation.Update()

                    Dim dbPop As New DataAccess.sqlDataBase("hp_accting")
                    Dim readerPop As SqlClient.SqlDataReader = dbPop.GetRecords("tax_Owner_Allocations", , "projection_year = '" & cmbYear.Text &
                            "' AND ocode = '" & reader.Item("ocode").ToString &
                            "' AND entity_num = '" & cmbEntity.Text.Substring(0, 8).Trim & "'", "allocation_code")

                    If readerPop.HasRows Then
                        While readerPop.Read

                            dtgAllocation.Rows(xRow).Cells(xColCount).Value = cmb.Items(readerPop.Item("percent_type"))
                            xRow = xRow + 1

                        End While

                    End If
                    dbPop = Nothing
                    readerPop = Nothing
                End While

            End If

            reader.Close()
            dtgAllocation.Update()