Answer the question
In order to leave comments, you need to log in
How to write from each line in a combobox with several words, separated by commas, into a new one, where is a new word on each line?
I have words separated by commas in each line in the combobox, how can I add one word at a time to the new combobox so that they do not repeat?
Answer the question
In order to leave comments, you need to log in
c - combobox.
var items = new List<string>();
foreach (var item in c.Items.Cast<string>())
{
foreach (var split in item.Split(','))
{
items.Add(split);
}
}
c.Items.Clear();
c.Items.AddRange(items.Distinct().ToArray());
c.Items.Cast<string>().ToList().ForEach(item => item.Split(',').ToList().ForEach(split => items.Add(split)));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question