如何创建没有图形的用户控件?如何使用c创建没有图形的用户控件#
当我使用Windows Form Control Library
创建用户控件时,我看到了这个命令行:public partial class UserControl1: UserControl
。 我的朋友告诉我用UserControl1:Component,IDisposable
替换UserControl1: UserControl
。 我不知道Component,IDisposable
是什么。
如何创建没有图形的用户控件?如何使用c创建没有图形的用户控件#
当我使用Windows Form Control Library
创建用户控件时,我看到了这个命令行:public partial class UserControl1: UserControl
。 我的朋友告诉我用UserControl1:Component,IDisposable
替换UserControl1: UserControl
。 我不知道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()
{
// ...
}
}
,并把它的形式:(你必须先重建,让它在工具箱中显示)
你在说什么是一个“组件”,它是从System.ComponentModel.Component
派生的任何类。控制是来自类System.Windows.Forms.Control
的特殊类型的组件。
如果你想让你自己的组件从Component
派生出来,这就是你的朋友用:Component,IDisposable
所做的。 IDisposable部分不需要,因为Component
已经实现IDisposeable
并且可以被关闭。
没有图形的用户控件是不是类? – John3136
它不是一个类,它是一个UserControl,我可以将其添加到ToolBox并拖动并形成 – AJHope
@ John3136不,认为Windows.Forms.Timer – Blorgbeard