Click here to Skip to main content
15,884,629 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
As a follow on to my question of yesterday (How do I Populate a Combobox from a SQL Datatable[^]) I have a new question.

My ComboBox is populated with the 3 entries from my test Database. If I click on the ComboBox I get the 3 entries as I would expect, if I don't select one and I just click on the ComboBox again, it closes and I can repeat this ad infinitum ... this is as I would expect.

If I then click on the ComboBox and Select one of them, let's say the middle one, the DropDown closes and the Selection is in the ComboBox, again, as I would expect.

However, if I then click on the ComboBox again (let's assume my User has Selected the wrong option), the Selection I made is now the first entry, the original first entry has gone, and the second entry, the one I Selected, has been replaced with either the text "System.Data.DataRowView" (If I have the ValueMember set to the Name from the Dataset) or if I have the ValueMember set to the ID from the Dataset, my Selection, when I re-open the ComboBox, is highlighted, still in second place, but the first entry is gone and has been replaced by the Number "2" ... I think the positioning is probably down to Sorting of the DatsTable.

If I cancel and rerun, everything is back to normal so nothing is really being Updated.
Posted
Comments
Tejas Vaishnav 8-Jan-14 8:19am    
can you post your code...

This is my code, Tejas, such as it is ...

VB
Public Class KAmail_Form1

    Private Sub KAmail_Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        Me.LeaguesTableAdapter.Fill(Me.DB_KAmailDataSet.Leagues)

        KAmail_ComboBox1.SelectedIndex = -1
        KAmail_ComboBox2.SelectedIndex = 0

    End Sub

    Private Sub KAmail_Button1_Click(sender As System.Object, e As System.EventArgs) Handles KAmail_Button1.Click

    End Sub

    Private Sub KAmail_Button2_Click(sender As System.Object, e As System.EventArgs) Handles KAmail_Button2.Click
        Me.Close()
    End Sub

End Class
 
Share this answer
 
I have done this differently, so this question / topic can be closed / deleted.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900