josef_skywalker josef_skywalker - 2 months ago 13
C# Question

Return a List of distinct values from DataGridView

As the topic says: Is there a way to return a list of distinct values from a certain Column of a DataGridView?

TaW TaW
Answer

This should do what you asked for:

var vv = dataGridView1.Rows.Cast<DataGridViewRow>()
                           .Select(x => x.Cells[yourColumn].Value.ToString())
                           .Distinct()
                           .ToList();
Comments