There are a few ways to start creating a new custom control in VS? Which one should I use? As in:
Right click project -> Add ->
1. User Control, or
2. Component, or
3. Custom Control, or?
I use #1 and get a partial class similar to:
namespace MyControls
{
partial class NewControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose ( bool disposing )
{
if ( disposing && ( components != null ) )
{
components.Dispose ( );
}
base.Dispose ( disposing );
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent ( )
{
components = new System.ComponentModel.Container ( );
//this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
#endregion
}
Why do I need this class? Is it only useful for composite controls where you need to use the designer?
EDIT: I know about the partial keyword and classes, but I don't know why I need this particular class for my custom control. It doesn't seem to make a difference.
This class contains the InitializeComponent
method, which is generated by the designer and contains all of the code necessary to create what you've made in the designer.
If you don't use the component designer at all, it is perfectly OK to delete this file (and the ResX file, if any) and remove the partial
keyword from your class declaration.
Note that deleting this file will permanently destroy anything you've made in the designer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With