Not sure where you're going wrong...it works for me with your exact code. I also created a blank component and added it as well:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication110
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
public partial class MyComponent : Component
{
}
public partial class ggDataBase : Component
{
private string _ConnectionString = "";
private SqlConnection connection = new SqlConnection();
private SqlDataAdapter adapter = new SqlDataAdapter();
private SqlCommand command = new SqlCommand();
public string ConnectionString
{
get { return _ConnectionString; }
set { _ConnectionString = value; }
}
public void FillDataTable(DataTable Table, string SqlText)
{
if ((connection.ConnectionString == null) || (connection.ConnectionString != _ConnectionString))
connection.ConnectionString = _ConnectionString;
if (connection.ConnectionString != null && connection.ConnectionString != "")
{
if (command.Connection == null)
command.Connection = connection;
command.CommandText = SqlText;
command.CommandType = CommandType.Text;
adapter.SelectCommand = command;
adapter.Fill(Table);
}
}
}
}
Here's an example designer file. Note that the components are declared and instantiated, but you will NOT see any of them (not even the built-in .Net components) explicitly being added to the "components" collection:
partial class Form1
{
/// <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 Windows Form 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()
{
this.components = new System.ComponentModel.Container();
this.myComponent1 = new WindowsFormsApplication111.MyComponent(this.components);
this.button1 = new System.Windows.Forms.Button();
this.ggDataBase1 = new WindowsFormsApplication111.ggDataBase();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components);
((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).BeginInit();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(55, 62);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// ggDataBase1
//
this.ggDataBase1.ConnectionString = "";
//
// contextMenuStrip1
//
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(61, 4);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 261);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private MyComponent myComponent1;
private System.Windows.Forms.Button button1;
private ggDataBase ggDataBase1;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.BindingSource bindingSource1;
}
And here's the output showing that the components were actually added (even yours):
WindowsFormsApplication111.MyComponent
System.Windows.Forms.Button
WindowsFormsApplication111.ggDataBase
System.Windows.Forms.Timer
System.Windows.Forms.ContextMenuStrip
System.Windows.Forms.BindingSource
That was generated by this code:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
foreach(Component C in EnumerateComponents())
{
Console.WriteLine(C.GetType().ToString());
}
}
// http://stackoverflow.com/a/17173320/2330053
private IEnumerable<Component> EnumerateComponents()
{
return from field in GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
where typeof(Component).IsAssignableFrom(field.FieldType)
let component = (Component)field.GetValue(this)
where component != null
select component;
}
}
Please see my previous comment with the link in it. Here's the article again:
A component can let the designer know that it would like to be
notified when its container goes away by implementing a public
constructor that takes a single argument of type IContainer, as shown
in this snippet. ... Notice that the constructor uses the container to
add itself as a container component. In the presence of this
constructor, the designer will generate code that uses this
constructor, passing it a container for the component to add itself
to.
Since you didn't provide that constructor, I can only guess that this is being done for you by the base class constructor. But I assure you, even though you don't have a line like that with components being passed in, your component is indeed being added to the collection. Look at the output from the previous code I posted above.