Is it possible to Implement generics for Forms and controls?

0
0

I wanted to ask if it was possible in one of the next versions to modify the designer so that it accepts object and/or form declarations with genericrs:

public partial class frmUser<T> : Form {
private T userInstance;

}

so that I can design a form that can be used for several instances of Example Objects:

var frmUserinfo = new frmUser<UserInfo>();

var frmUserRegistry = new frmUser<UserRegistry>(p1, p2,…);

I think from the designer’s point of view it is sufficient to ignore in design time the Generics type.

This would allow me to design my forms/controls more efficiently. It would really be greatly appreciated….

If by chance there is already the possibility at the limit I would ask for some examples.

As always, thank you very much

  • You must to post comments
0
0

Hi Tiziano,

Unfortunately, this would be impossible to implement.

The designer creates an instance of the base class and applies the designing class’s instructions (interpreted) in InitializeComponent(). Cannot create an instance of the generic class. You need a class in between, basically something along the lines of MyForm : FormInBetween: FormGeneric<FormTest>

Best,
Alaa

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.