简体   繁体   English

创建没有设计器的winform用户控件

[英]Creating a winform user control with no designer

How do I create a WinForms User Control that has no GUI or designer attachment? 如何创建没有GUI或设计器附件的WinForms用户控件? An example is like the Timer Control, which you drop onto your form and it docks to the bottom but doesn't have any GUI controls? 一个例子就像定时器控件,它放在你的表单上,它停靠在底部,但没有任何GUI控件?

You need to use System.ComponentModel.Component as base class . 您需要使用System.ComponentModel.Component作为base class

Example : 示例:

class Class1 : System.ComponentModel.Component
{

}

Class1是一个组件!

Create a class that inherits from System.Windows.Forms.Control. 创建一个继承自System.Windows.Forms.Control的类。 This should change the icon from the normal "class" icon to a "component" icon in the solution explorer. 这应该将图标从正常的“类”图标更改为解决方案资源管理器中的“组件”图标。 You can see this effect if creating a class and inheriting from say TextBox or Timer 如果创建一个类并继承自TextBox或Timer,您可以看到这种效果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM