Skip to content

Is it possible to Implement generics for Forms and controls? #4327

Closed

Description

@itg-assistant

Tiziano Salardini asked 2023-09-20 15:19:39 UTC

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.

As always, thank you very much

Activity

  1. itg-assistant commented on Jun 15, 2026

    @itg-assistant
    Author

    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

  2. itg-assistant commented on Jun 15, 2026

    @itg-assistant
    Author

    Tiziano Salardini answered 2023-09-26 08:35:05 UTC

    I understand, thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    SuggestionAn improvement to something that already works.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions