I’ve made a function in C#:
private void customShow(Form someForm, Type formType) {
if (someForm == null || someForm.IsDisposed) someForm = (Form)Activator.CreateInstance(formType);
someForm.StartPosition = FormStartPosition.CenterScreen;
someForm.MdiParent = this;
someForm.Show();
someForm.WindowState = FormWindowState.Maximized;
}
And then I wanted to do this:
private void mnuKategori_Click(object sender, EventArgs e) {
customShow(frmKategori, typeof(Master.FrmKategori));
frmKategori.isCRUD = true;
}
It failed on the method’s second line because the variable frmKategori is still null after the method execution. If I make the “someForm” argument into reference, it also fails because it seems C# doesn’t support polymorphism with “ref” and “out” keyword. Does anybody have a suggestion on this?
Thanks in advance for the reply.
Generics perhaps?
And then I wanted to do this: