Visual Studio Express is a lightweight version of VS products and although it is very powerful, it is missing several features from paid editions and one of them is ability to add a Component Class using Add New Item dialog box.
But users of Express editions can still create Component Class by following the steps below:
- Using Add New Item dialog box, add a User Control and name it Component1 .
- select
Component1.cs
and choose View Code to view the code. Now delete everything and replace it with the following code.using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Text; namespace EmptyComponent { public partial class Component1 : Component { public Component1() { InitializeComponent(); } public Component1(IContainer container) { container.Add(this); InitializeComponent(); } } }
- Rename the namespace to the one you are using. Visual Studio will give your namespace same name as your project name.
- Go to
Component1.Designer.cs
and remove the following line inInitializeComponent
method. Method is located in Component Designer generated code region, so expand that region if necessary.this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
And you are done.
If you found this article useful, drop a comment or connect with the blog on the social networks.
EdG
March 7, 2014Nice. Just what I needed to create a component in my VS2013 Express.