Hi guys I´m trying to set a form variable that was created like this
var type = Type.GetType("namespace." + "formName");
Form form = Activator.CreateInstance(type) as Form;
The varible was created in the form designer
public int myVariable = 0;
What a I roughly want it to do is something like form.variable = 7 I tried this:
form.GetType().GetProperty(propertyName).SetValue(form, 7, null);
But it doesn't work :(
EDIT Sorry guys if didn't explain myself, I'll try to be more specific
private void ShowForm(string frmname, string propertyName, int propertyValue)
{
var type = Type.GetType("RetailSystem.Compras." + frmname);
Form form = Activator.CreateInstance(type) as Form;
if (form != null)
{
// Set variables
form.Show();
}
}
This function will recieve a string which is the name of the form
Aucun commentaire:
Enregistrer un commentaire