qur in comboboxes

srivalli

Well-known member
Joined
May 4, 2005
Messages
189
Programming Experience
Beginner
in my form i have written the code for combobox as follows

Private Sub ComboBox1_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.DropDown

ComboBox1.DisplayMember = "shortform"
ds1.Clear()
da1.Fill(ds1, "p")
ComboBox1.DataSource = ds1.Tables("p")

End Sub
my query is when i am selecting the combobox for the first time ,say if i have 4 items ,the items are bieng displayed
but when i am selecting the combobox for the second time then the items are displyed twice and so on
so i want to display the items as it is without repitition even though i click any number of times
hope my question is clear
any suggestions
thanks
 
i think the error is that you put that code in the DropDown event

you should put the
ComboBox1.DataSource = ds1.Tables("p")
ComboBox1.DisplayMember = "shortform"

in the load event of the form (the combobox's contents will change whenever the ds1 dataset is changed, fyi)

and then the
ds1.Clear()
da1.Fill(ds1, "p")

could go in the load event and/or whereever else it may be needed to be called (like a SelectedIndexChanged event of another listbox or combobox, or a save/delete button if one is added or removed)
 
Back
Top