I get the distinct values from a Datatable
with the code below. This is very slow. With 9000 unique values I stopped the reading after 2 minutes. Is it possible to do it faster?
private void GetWaarde(string Veldnaam)
{
if (DatatabelExport.Rows.Count > 0)
{
Cursor.Current = Cursors.WaitCursor;
DataGridViewComboBoxColumn cb = (DataGridViewComboBoxColumn)dataGridView3.Columns["Waarde"];
if (cb.Items.ToString() != "") //als veld Waarde al gevuld is dan niet opnieuw vullen
{
var x = (from r in DatatabelExport.AsEnumerable()
select r[dataGridView1.Columns[Veldnaam].Name]).Distinct().ToList();
for (int i = 0; i < x.Count - 1; i++)
{
cb.Items.Add(x[i].ToString());
}
}
cb.Dispose();
Cursor.Current = Cursors.Default;
}
}