public virtual void SetItems(object editValue, object[] values) { IList list = editValue as IList; Array array = editValue as Array; if (list != null) { list.Clear(); foreach (var o in values) list.Add(o); } else if (array != null) { Array.Copy(values, array, values.Length); } } }
private void btnOK_Click(object sender, EventArgs e) { object[] values = new object[lines]; for (int i = 0; i < textBox1.Lines.Length; i++) { string line = textBox1.Lines[i]; values[i] = Convert.ChangeType(line, editor.CollectionItemType); } editor.SetItems(value, values); }