private void btn_create_Click(object sender, EventArgs e) { int a = compounds.Count; Composite c = new Composite(); foreach (Component b in formula) { c.addComponent(b); } c.setCyclic(isCyclic); compounds.Add(c); lb_newCompound.Items.Clear(); Composite temp = (Composite)compounds[a]; lb_compoundList.Items.Add(temp.getName()); int d = temp.getChildCount(); for (int i = 0; i < d; i++) { Component child = temp.getChild(i); lb_compoundList.Items.Add(" " + child.getName()); } formula.Clear(); isCyclic = false; }