I have a form that allows you to add multiple product ids to a buy. screenshot!
When you start the program here is what you see!
So every time you press a plus button another row appears!.
In order to avoid too many lines of code I decided to create a function so that it takes the number or the row where the plus button was pressed and adds 1 to it, so that the next row appears.
Right now it returns a string with the code, but I dont know how to execute it..
I have searched how to execute a string but the solution can never apply to my code.
//function
public string plus(int n)
{
string r="";
r = "label" + (n + 1) + ".Visible = true;";
r += "combobox" + (n + 1) + ".Visible = true;";
r += "plusButton" + (n + 1) + ".Visible = true;";
r += "minusButton" + (n + 1) + ".Visible = true;";
return r;
}
//plus button
private void plus1_Click(object sender, EventArgs e)
{
//code to execute (plus(1));
}
Opinions and sugestions would be greatly appreciated, solutions even more!