How prevent duplicates in combobox in windowsapplication using c#?
how to prevent duplicates in combobox in windowsapplication using c#?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
mangesh shelar13 reputationPosted Sep 7, 2011, 3:39 AM EDT
Vilas GiteRank #951 · 2.1K reputationPosted Sep 7, 2011, 6:26 AM EDT
Hi Srinivas!
You can bind data from store procedure to combobox with primary key column table.
Thanks!
-----------------------------------------------------------------------
If this reply helps your post…then check "This is correct answer"
VulpesRank #55 · 29.2K reputationPosted Sep 7, 2011, 10:01 AM EDT
Satyapriya NayakRank #47 · 31.5K reputationPosted Sep 7, 2011, 10:36 AM EDT
SELECT columnname FROM tablename GROUP BY columnname
Then bind the query to combobox
as
con.Open();
str = "select sname from student GROUP BY sname";
com = new SqlCommand(str, con);
SqlDataReader reader = com.ExecuteReader();
while (reader.Read())
{
comboBox1.Items.Add(reader["sname"]);
}
reader.Close();
con.Close();
Thanks