I’m filling a ComboBox with DataGridView cells’ values. Now, I don’t want to repeat values which already are in the ComboBox.
So, there is for example:
- Bill Gates
- Steave Jobs
- Steave Ballmer
- Steave Jobs
I want to remove all values which appear more than once.
This is my code:
private void btnFilter_Click(object sender, EventArgs e)
{
ArrayList SellerNameList = new ArrayList();
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
SellerNameList.Add(dataGridView1.Rows[i].Cells["cSellerName"].Value);
}
comboBox1.DataSource = SellerNameList;
}
Sorry for my bad English.
Seems like you want a unique list for the
dataSourcefor your ComboBox. If you are using .NET 3 and above you can use: