private void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { ListBox box = sender as ListBox; LibFromSourceField selectfield = box.SelectedItem as LibFromSourceField; foreach (Control item in this.splitContainer1.Panel2.Controls) { if (item.Name == selectfield.ID) { ModelDesignProject.SetControlVisible(item, this.splitContainer1.Panel2.Controls); break; } } }
/// <summary> /// 新增按钮点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button1_Click(object sender, EventArgs e) { LibFromSourceField fromSourceField = new LibFromSourceField(); fromSourceField.ID = Guid.NewGuid().ToString(); this.listBox1.Items.Add(fromSourceField); FromSourceProperty sourceProperty = new FromSourceProperty(fromSourceField.ID); sourceProperty.Dock = DockStyle.Fill; this.splitContainer1.Panel2.Controls.Add(sourceProperty); sourceProperty.SetPropertyValue(fromSourceField, null); ModelDesignProject.SetControlVisible(sourceProperty, this.splitContainer1.Panel2.Controls); //SetPanel2ControlsVisible(sourceProperty); }