如何创建没有图形的用户控件?
当我使用创建用户控件时Windows Form Control Library
,看到了以下命令行:public partial class UserControl1: UserControl
。我的朋友告诉我,以取代UserControl1: UserControl
用UserControl1:Component,IDisposable
。我不知道什么Component,IDisposable
是。
如果您查看可以放到窗体上的其他组件之一,而这些组件没有自己的界面,则可以看到您的朋友在谈论什么:
public class BackgroundWorker : Component
public class ErrorProvider : Component, IExtenderProvider, ISupportInitialize
public class Timer : Component
您可以轻松创建自己的:
public class MyVeryOwnComponent : Component
{
public string Setting1 { get; set; }
public string Setting2 { get; set; }
public void SomeImportantMethodYouCanCall()
{
// ...
}
}
并将其放在您的表单上:(您必须先进行重建,才能使其显示在工具箱中)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句