C#泛型用户控件 [英] C# generics usercontrol
本文介绍了C#泛型用户控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想定义以下控制:
公共部分类ObjectSelectorControl< T> :用户控件其中T:类
的问题是,设计者无法解决这个问题。有一种解决方法这个问题?
解决方案
本作品
公共类控制1< T> :用户控件{...}
公共类控制2:控制1<双> {...}
公共类CONTROL3:控制2 {...}
块引用>
曾在这里阅读:
的 http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/0c265543-d6f0-41f6-beeb-b89e0071c5c3
I would like to define the following control:
public partial class ObjectSelectorControl<T> : UserControl where T : class
The problem is that the designer can't resolve this. Is there a workaround to this issue?
解决方案This works
public class Control1<T> : UserControl { ... } public class Control2 : Control1<double> { ... } public class Control3 : Control2 { ... }
had read it here:
http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/0c265543-d6f0-41f6-beeb-b89e0071c5c3
这篇关于C#泛型用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文