public bool AddComboItem(string str, object obj) { if (dictionary.ContainsKey(str) == false) // Check for duplicates { dictionary.Add(str, obj); comboBox.Items.Add(str); if (obj is Form) { Form form = (Form)obj; form.CreateControl(); form.TopLevel = false; form.Parent = this; form.Dock = DockStyle.None;// | DockStyle.Right | DockStyle.Bottom; form.FormBorderStyle = FormBorderStyle.None; form.Location = new System.Drawing.Point(0, 8 + comboBox.Size.Height); form.Size = new System.Drawing.Size(this.Size.Width - 3, this.Size.Height - 9 - comboBox.Size.Height); this.Controls.Add(form); } if (selectedObj == null) { comboBox.SelectedIndex = 0; selectedObj = obj; if (obj is Form) { ((Form)selectedObj).Show(); } } return(true); } return(false); }
public void AddForm(FormViewModel formViewModel, string formName) { FormDictionary.Add(formName, formViewModel); }