internal void addButton_Click(object sender, EventArgs e) { if (this.searchList.Controls.Count > 0) { SearchUserControl searchCtrl = (SearchUserControl)this.searchList.Controls[this.searchList.Controls.Count - 1]; if (searchCtrl.operatorComboBox.SelectedItem != null) { searchControl = new SearchUserControl(); searchControl.controlDiction = controlDiction; string[] arrayItems = fieldNameArray.ToArray(); searchControl.fieldList.Items.AddRange(arrayItems); this.searchList.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20)); searchControl.removeButton.Click += new EventHandler(removeButton_Click); this.searchList.Controls.Add(searchControl); rowCounter++; } else { MessageBox.Show("Operator needs to be selected before adding new condition"); } } else { searchControl = new SearchUserControl(); searchControl.controlDiction = controlDiction; string[] arrayItems = fieldNameArray.ToArray(); searchControl.fieldList.Items.AddRange(arrayItems); this.searchList.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20)); searchControl.removeButton.Click += new EventHandler(removeButton_Click); this.searchList.Controls.Add(searchControl); rowCounter++; } }