problems sorting a combobox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DeWittds
    New Member
    • Oct 2006
    • 11

    problems sorting a combobox

    I have a combo box that I can not get to sort correctly. I fill the combobox with a customer id and name ( combined) have set the combobox.sorted = true
    I saw one Idea here about turning the .sorted of the back on, but then the combobox list showed the same customerID all the way down the list.

    Thanks for any help,
    David

    the data comes from a dataset and put into the combobox with the following code

    Code:
        
    Private Sub FillList()
            ' use this sub to fill or refill the cusomer id list  
            ' for the following events: add, update, delete customers
            Me.ComboBox_CustomerID.Items.Clear()
    
            Dim p As id_storename = New id_storename()
            Dim findinc As Integer
            findinc = 0
    
            Do While findinc <> MainForm.MaxRows
                p.tmp_ID = ds.Tables("AddressBook").Rows(findinc).Item("CustID")
                p.tmp_StoreName = ds.Tables("AddressBook").Rows(findinc).Item("CompanyName")
                Me.ComboBox_CustomerID.Items.Add(p)
                findinc = findinc + 1
            Loop
            ComboBox_CustomerID.Focus()
        End Sub
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    One way to do this is to create a dataview and use the dataview.sort method before binding it to the combobox...

    Hope that this helps.

    Comment

    • DeWittds
      New Member
      • Oct 2006
      • 11

      #3
      I guess that would do it, but shouldn't the combobox.sorted work and if so is there a known problem with.

      Thanks



      Originally posted by kenobewan
      One way to do this is to create a dataview and use the dataview.sort method before binding it to the combobox...

      Hope that this helps.

      Comment

      • kenobewan
        Recognized Expert Specialist
        • Dec 2006
        • 4871

        #4
        Apparently, if you have combobox.sorted = true you cannot set DataSource. Remove it. This may mean that your existing code will work. I suggested the dataview as this is the way that I normally do it.

        Hope that this helps.

        Comment

        Working...