You can use Dictionary to map values ββin selected elements to forms, or perhaps even more efficient functions that a form can create (to provide lazy loading).
private Dictionary<string, Func<Form>> formMapping = new Dictionary<string, Func<Form>>() { {"House", ()=> new House()}, {"People", ()=> new People()}, {"Outdoor", ()=> new Outdoor()}, };
Then you can use this mapping in the click event handler to translate the selected value into the form:
private void button1_Click(object sender, EventArgs e) { Form newForm = formMapping[listBox1.SelectedValue](); newForm.ShowDialog(); }
Servy source share