You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Is it possible to Implement generics for Forms and controls? #4327
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 : 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();
...
var frmUserRegistry = new frmUser(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.
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
Activity
itg-assistant commentedon Jun 15, 2026
Alaa (ITG) answered 2023-09-22 12:46:07 UTC
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
Best,
Alaa
itg-assistant commentedon Jun 15, 2026
Tiziano Salardini answered 2023-09-26 08:35:05 UTC
I understand, thank you very much