I'm creating User controls based on which button is clicked, but trying to use as little code as possible to keep my project clean.
So instead of writing the same code in each button_click controller I planned to call the void WhichController
string ControlName = "UserControl";
string ControlNamePath = "FormProject.";
private void button2_click(object sender, EventArgs e){
int controllernumber += 3;
WhichController();
}
private void WhichController(){
var ControllerDisplay = ControlNamePath + ControlName + Controllernumber;
ControllerDisplay Controllershow = new ControllerDisplay();
panel1.Controls.Add(Controllershow);
}
I keep getting ControllerDisplay is a variable but is used like a type. Is there anyway around this? Suggestion on method change are welcome.