Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make windows form generic

Tags:

c#

winforms

One year after a similare question has been posted on SO. Generic Windows Form Template

Do you know if there're a better way to make a windows form generic, here's what I'd like to do:

public partial class EntryPointEditForm<T>  : Form where T : ICriteriaObject<T>
{}

But an error is thrown telling me that: no suitable method found to override
on the method:

protected override void Dispose(bool disposing)
like image 865
John Avatar asked Sep 26 '26 08:09

John


1 Answers

You need to change the partial class declaration in the .Designer.cs file to also be generic.

However, I don't think that the VS designer supports generic form classes.
You may need to make a non-generic abstract form to use with the designer, then make a generic class that inherits from it for you to actually use.

like image 139
SLaks Avatar answered Sep 28 '26 21:09

SLaks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!