public void Add(AskAndAnswer question) { QuestionsControl control = new QuestionsControl(Entries); control.InitTexts(); control.Width = flowLayoutPanel.Width - 40; control.Question = question; flowLayoutPanel.Controls.Add(control); }
private void buttonAdd_Click(object sender, EventArgs e) { int currentIndex = Parent.Controls.GetChildIndex(this); for (int i = currentIndex + 1; i < Parent.Controls.Count; i++) Parent.Controls.SetChildIndex(Parent.Controls[i], i); QuestionsControl control = new QuestionsControl(); control.InitTexts(); control.Width = Parent.Width - 40; Parent.Controls.Add(control); Parent.Controls.SetChildIndex(control, currentIndex + 1); }