使Windows窗体通用 [英] Make windows form generic

查看:52
本文介绍了使Windows窗体通用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在SO上发布相似问题一年后.常规Windows表单模板

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

您知道是否有更好的方法来使Windows窗体通用,这是我想做的事情:

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)

推荐答案

您需要将 .Designer.cs 文件中的部分类声明也更改为通用的.

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

但是,我不认为VS设计器支持通用表单类.
您可能需要制作一个非通用的抽象形式以与设计器一起使用,然后制作一个从其继承的通用类供您实际使用.

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.

这篇关于使Windows窗体通用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆