I need your help! I have wrote a function which save the "ID" from a Textfile to a Combobox.
Thats working, now i want to read the "ID" and under the id the values in the textfile when i select the combobox.
Its like
"ID" = L1 220313 100
Values =
- 1 13
- 1 25
- 1 33
So now i want to get the Values which start With 1 in different textboxes, like value 1 13 in textbox1, and so on. But i dont know how to save the startswith in different strings to use them in different ways..
I found this code here in stackoverflow so maybe you know this code
var lines = System.IO.File.ReadAllLines("")
.Select(l => l.Trim())
.Where(l => l.StartsWith(l_id // the number));
comboBox1.Items.Add(String.Join(Environment.NewLine, lines));
this is used to get the ID in the combobox, but i dont know how get the values under the id out of this...
i need something like this
var sectionName = comboBox1.SelectedItem;
string[] items =
File.ReadLines(fileName) //read file lazily
.SkipWhile(line => line != sectionName) //search for header
.Skip(1) //skip header
.TakeWhile(line => !string.IsNullOrEmpty(line))//take until next header
.ToArray();
Source: Read specific line in text file
Thanks in advance!