4

How do I create a WinForms User Control that has no GUI or designer attachment? 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?

2 Answers 2

5

You need to use System.ComponentModel.Component as base class.

Example :

class Class1 : System.ComponentModel.Component { } 

Class1 is a component!

Sign up to request clarification or add additional context in comments.

3 Comments

This article will really help anyone. msdn.microsoft.com/en-us/library/9hk12d4y.aspx
How can I read property ParentForm as with Control base class?
@Yogurtu: A Component has Container and Site properties, which have similar functionality to Parent and ParentForm in GUI controls. When you drop a component onto the designer, the designer automatically generates code that sets these
0

Create a class that inherits from 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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.