mercredi 1 avril 2015

Create and SHow Forms c#

I´m trying to create and show forms in VS 2013 with a generic method this is my method:



void showOrUpdateForm<T>(ref Form form) where T : Form
{
if (form == null)
{
form = Activator.CreateInstance(typeof(T)) as T;
form.Show();
}
else
form.WindowState = FormWindowState.Normal;

form.Focus();
}


this code i got it from here. So when i try to call this method like they told like that:



myForm1 form;
showOrUpdateForm<myForm1>(ref form);


It give me error:


Error 1 The best overloaded method match for 'GestionEAS.GestionEAS.showOrUpdateForm(ref System.Windows.Forms.Form)' has some invalid arguments


Error 2 Argument 1: cannot convert from 'ref package.Views.form' to 'ref System.Windows.Forms.Form'


How can I fix this?


Aucun commentaire:

Enregistrer un commentaire