Im trying to figure out how to run through the collection of TextBoxes and check that the text is unique.
Any ideas?
This post has been edited by scolty: 07 February 2012 - 10:42 AM




Posted 07 February 2012 - 12:03 PM
var textBoxes = Controls.OfType<TextBox>().GroupBy(t => t.Text.ToLower()).ToList(); var unique = textBoxes.Where(g => g.Count() == 1).SelectMany(g => g); var duplicates = textBoxes.Where(g => g.Count() > 1).SelectMany(g => g); unique.ToList().ForEach(t=>t.BackColor = Color.Green); duplicates.ToList().ForEach(t => t.BackColor = Color.Red);
