Here you go..
I used 2 textBoxes just replace it with richttextbox.text and your settested and works
Here is an preview of the outputCode:private List<string> Chains = new List<string>(); private List<List<string>> ContentChains = new List<List<string>>(); private void button1_Click(object sender, EventArgs e) { string[] linesArray = textBox1.Text.Split('\n'); int chainNr; foreach (string s in linesArray) { String[] array = s.Split(' '); if (!Chains.Contains(array[4])) { Chains.Add(array[4]); ContentChains.Add(new List<string>()); } chainNr = Chains.IndexOf(array[4]); List<string> list = ContentChains.ElementAt(chainNr); list.Add(array[3]); } } //Used to show values in another textbox private void button2_Click(object sender, EventArgs e) { int i = 0; foreach (String s in Chains) { textBox2.Text += "Chain " + s + Environment.NewLine; List<string> list = ContentChains.ElementAt(i); int j=0; foreach (String st in list) { textBox2.Text += j + " " + st + Environment.NewLine; j++; } i++; } }
Chain A
0 GLY
1 GLY
2 GLY
Chain B
0 GLY
1 GLY
2 GLY
3 GLY
greetz kristof




tested and works 
Reply With Quote