Hier ist der Code. Hilfe wird sehr verpflichtet sein. Ich möchte, dass die Panels zu tabePage1 hinzugefügt werden, aber stattdessen dem Formular hinzugefügt werden.Wie füge ich diese Panels tabcontrol hinzu, anstatt sie dem Formular hinzuzufügen?
private void tabPage1_Click(object sender, EventArgs e)
{
int i, j;
for (i = 1; i <= 3; i++)
{
for (j = 1; j <= 4; j++)
{
Panel a = new Panel();
a.Location = new Point(i * 200, j * 50);
a.Width = 180;
a.Height = 40;
a.Name = "Rom " + (((i * 4) - 3) + (j - 1));
a.BackColor = Color.Yellow;
a.AllowDrop = true;
a.DragDrop += new System.Windows.Forms.DragEventHandler(this.panel1_DragDrop);
a.DragOver += new System.Windows.Forms.DragEventHandler(this.panel1_DragOver);
a.Visible = true;
Label l = new Label();
l.Location = new Point(10, 10);
l.Width = 180;
l.Text = a.Name;
a.Controls.Add(l);
l.AllowDrop = true;
this.Controls.Add(a);
tabPage_Click ist wahrscheinlich das falsche Ereignis zu versuchen, und dies mit zu tun. – LarsTech